Async Jobs and Scheduling in Django

Ritwick Raj
AnitaB.org Open Source
2 min readJul 21, 2020

Asynchrony¹ refers to the occurrence of events independent of the main program flow and ways to deal with such events. These may be “outside” events such as the arrival of signals, or actions instigated by a program that take place concurrently with program execution, without the program blocking to wait for results. Asynchronous input/output is an example of the latter cause of asynchrony, and lets programs issue commands to storage or network devices that service these requests while the processor continues executing the program. Doing so provides a degree of parallelism.

In Django this job can be done by using a few libraries, some of which are:

  • Celery Django
  • ApScheduler
  • Django Q

Having a job in hand to schedule emails, I chose to work with Django Apscheduler for its simplicity and framework friendly environment.

Here are the following steps one has to follow to get the scheduler up and running in Django.

Making Changes in the settings.py

Creating the Scheduler

Triggering the Scheduler to start as soon as Django Server Starts

Adding Jobs to the Scheduler

This is how you add async jobs in Django. When up and running, the django admin would look something like this:

Happy Reading :)

--

--