Last active
August 29, 2015 14:24
-
-
Save zfz/c63ee5a3b65d6ecd0f6f to your computer and use it in GitHub Desktop.
schedule decorator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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