Skip to content

Instantly share code, notes, and snippets.

@ahawker
Created March 14, 2013 20:57
Show Gist options
  • Save ahawker/5165205 to your computer and use it in GitHub Desktop.
Save ahawker/5165205 to your computer and use it in GitHub Desktop.
Crython example per request from user.
import crython
import time
@crython.job(second='*') #fired every second
def hello_world():
print 'hello_world called every second.'
@crython.job(second='*/4') #fired every 4 seconds
def hello_fours():
print 'hello_fours called every 4 seconds.'
if __name__ == '__main__':
crython.tab.start() #start the global cron tab scheduler which runs in a background thread
time.sleep(10) #sleep main thread for 10 seconds so we can see jobs being fired
#test.py STDOUT below >>>
#C:\Python27\python.exe C:/Users/arhawker/Downloads/crython-master/crython-master/test.py
#hello_world called every second.
#hello_world called every second.
#hello_world called every second.
#hello_fours called every 4 seconds.
#hello_world called every second.
#hello_world called every second.
#hello_world called every second.
#hello_world called every second.
#hello_fours called every 4 seconds.
#hello_world called every second.
#hello_world called every second.
#hello_world called every second.
#Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment