Frequently Asked Questions¶
Why doesn’t the scheduler run my jobs?¶
This could be caused by a number of things. The two most common issues are:
- Running the scheduler inside a uWSGI worker process while threads have not been enabled (see the next section for this)
- Running a
BackgroundSchedulerand then letting the execution reach the end of the script
To demonstrate the latter case, a script like this will not work:
from apscheduler.schedulers.background import BackgroundScheduler def myjob(): print('hello') scheduler = BackgroundScheduler() scheduler.start() scheduler.add_job(myjob, 'cron', hour=0)
The script above will exit right after calling
add_job() so the scheduler will not have a
chance to run the scheduled job.
If you’re having any other issue, then enabling debug logging as instructed in the Troubleshooting section should shed some light into the problem.
How can I use APScheduler with uWSGI?¶
uWSGI employs some tricks which disable the Global Interpreter Lock and with it, the use of threads
which are vital to the operation of APScheduler. To fix this, you need to re-enable the GIL using
--enable-threads switch. See the uWSGI documentation for more details.
Also, assuming that you will run more than one worker process (as you typically would in production), you should also read the next section.
How do I use APScheduler in a web application?¶
First read through the previous section.
If you’re running Django, you may want to check out django_apscheduler. Note, however, that this is a third party library and APScheduler developers are not responsible for it.
Likewise, there is an unofficial extension called Flask-APScheduler which may or may not be useful when running APScheduler with Flask.
For Pyramid users, the pyramid_scheduler library may potentially be helpful.
Other than that, you pretty much run APScheduler normally, usually using
BackgroundScheduler. If you’re running an asynchronous
web framework like aiohttp, you probably want to use a different scheduler in order to take some
advantage of the asynchronous nature of the framework.
Is there a graphical user interface for APScheduler?¶
No graphical interface is provided by the library itself. However, there are some third party implementations, but APScheduler developers are not responsible for them. Here is a potentially incomplete list: