Skip to content

Instantly share code, notes, and snippets.

@zfz
Last active August 29, 2015 14:24
Show Gist options
  • Save zfz/c63ee5a3b65d6ecd0f6f to your computer and use it in GitHub Desktop.
Save zfz/c63ee5a3b65d6ecd0f6f to your computer and use it in GitHub Desktop.
schedule decorator
import schedule
import time
def scheduled(t):
def wrapper(func):
schedule.every(7).days.at(t).do(func)
while True:
schedule.run_pending()
time.sleep(1)
return func(*args, **kwargs)
return wrapper
if __name__ == '__main__':
@scheduled(t="17:15")
def job():
print("I'm working...")
job()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment