Skip to content

Instantly share code, notes, and snippets.

@eristoddle
Created September 19, 2012 17:30
Show Gist options
  • Save eristoddle/3750962 to your computer and use it in GitHub Desktop.
Save eristoddle/3750962 to your computer and use it in GitHub Desktop.
Very Tiny Python Job Server
#!/usr/bin/python
from lib import scheduler
import datetime, time
def eristoddle_post_server(every_min, run_time_min):
from core.myWP import zem_cb_eristoddle
every_sec = 60 * every_min
run_time = 60 * run_time_min
esched = scheduler.Scheduler()
etask = scheduler.Task("eristoddle_post",
datetime.datetime.now(),
scheduler.every_x_secs(every_sec),
scheduler.RunOnce(zem_cb_eristoddle))
esched.start()
receipt = esched.schedule_task(etask)
print receipt
print 'sleeping for %s sec...' % (run_time)
time.sleep(run_time)
print 'waking up and killing scheduler'
esched.halt()
if __name__ == "__main__":
eristoddle_post_server(2,4000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment