Implementing the scheduler

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) ...

Get Mastering RabbitMQ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.