We will start off with the base code of the producer. If you can think about it, you'll find that we're only missing the scheduling piece from it.
For actual scheduling, we'll use the cool schedule
library. Let's get it with pip
:
$ pip install schedule Downloading/unpacking schedule Downloading schedule-0.3.1.tar.gz Running setup.py (path:/private/var/folders/gw/xp4xsqt97957cc7hcgxd0w0c0000gn/T/pip_build_dotan/schedule/setup.py) egg_info for package schedule Installing collected packages: schedule Running setup.py install for schedule Successfully installed schedule
And we're done. Here's how we can use schedule
(from the documentation):
import schedule import time def job(): print("I'm working...") schedule.every(10).minutes.do(job) schedule.every().hour.do(job) schedule.every().day.at("10:30").do(job) schedule.every().monday.do(job) schedule.every().wednesday.at("13:15").do(job) while True: schedule.run_pending() time.sleep(1)
Because schedule
is so developer...