Skip to content

Commit

Permalink
deps: Clarify limitations of using APScheduler < 4.0. Pin APScheduler…
Browse files Browse the repository at this point in the history
… dependency to avoid breaking changes.
  • Loading branch information
jcass77 committed Oct 16, 2020
1 parent fd01b22 commit 1d74bdb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ actively running at a particular point in time**.

This limitation stems from the fact that APScheduler does not currently have any [interprocess synchronization and
signalling scheme](https://apscheduler.readthedocs.io/en/latest/faq.html#how-do-i-share-a-single-job-store-among-one-or-more-worker-processes)
that would enable the scheduler to be notified when a job has been added, modified, or removed from a job store. A
typical Django [deployment in production](https://docs.djangoproject.com/en/dev/howto/deployment/#deploying-django)
will start up more than one worker process, and if each worker process ends up running its own scheduler then this could
result in jobs being missed or executed multiple times, as well as duplicate entries in the `DjangoJobExecution` tables
being created.
that would enable the scheduler to be notified when a job has been added, modified, or removed from a job store.

Support for persistent job store sharing among multiple schedulers appears to be planned for an [upcoming APScheduler
4.0 release](https://github.com/agronholm/apscheduler/issues/465). Until then, a typical Django [deployment in
production](https://docs.djangoproject.com/en/dev/howto/deployment/#deploying-django) will start up more than one
worker process, and if each worker process ends up running its own scheduler then this could result in jobs being
missed or executed multiple times, as well as duplicate entries in the `DjangoJobExecution` tables being created.

So your best options are to either:
So for now your options are to either:

1. Use a custom Django management command to start a single scheduler in its own dedicated process (**recommended** -
see the `runapscheduler.py` example below); or
Expand Down Expand Up @@ -64,7 +66,7 @@ Features of this package include:
![Jobs](docs/screenshots/run_now.png)

- **Note:** In order to prevent long running jobs from causing the Django HTTP request to time out, the combined maximum
run time for all APScheduler jobs that are started via the Django admin site is 15 seconds. This timeout value can be
run time for all APScheduler jobs that are started via the Django admin site is 25 seconds. This timeout value can be
configured via the `APSCHEDULER_RUN_NOW_TIMEOUT` setting.

Installation
Expand Down Expand Up @@ -102,7 +104,7 @@ APSCHEDULER_DATETIME_FORMAT = "N j, Y, f:s a"
# Longer running jobs should probably be handed over to a background task processing library
# that supports multiple background worker processes instead (e.g. Dramatiq, Celery, Django-RQ,
# etc. See: https://djangopackages.org/grids/g/workers-queues-tasks/ for popular options).
APSCHEDULER_RUN_NOW_TIMEOUT = 15 # Seconds
APSCHEDULER_RUN_NOW_TIMEOUT = 25 # Seconds
```

- Run `python manage.py migrate` to create the django_apscheduler models.
Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This changelog is used to track all major changes to django-apscheduler.

## v0.5.1 (UNRELEASED)

**Fixes**

- Pin dependency to APScheduler < 4.0, which appears to be introducing some [backwards incompatible changes](https://github.com/agronholm/apscheduler/issues/465).
- Update readme to clarify the need for ensuring that a single scheduler is run in your Django application until
APScheduler 4.0 arrives and django-apscheduler is migrated to make use of that version.
- Update authors section in `setup.py`.


## v0.5.0 (2020-10-13)

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
long_description=long_description,
long_description_content_type="text/markdown",
url="http://github.com/jarekwg/django-apscheduler",
author="Jarek Glowacki, Stas Kaledin",
author_email="[email protected], [email protected]",
author="Jarek Glowacki, Stas Kaledin, John Cass",
author_email="[email protected], [email protected], [email protected]",
license="MIT",
classifiers=[
"Development Status :: 4 - Beta",
Expand All @@ -35,6 +35,6 @@
],
keywords="django apscheduler django-apscheduler",
packages=find_packages(exclude=("tests",)),
install_requires=["django>=2.2", "apscheduler>=3.2",],
install_requires=["django>=2.2", "apscheduler>=3.2,<4.0", ],
zip_safe=False,
)

0 comments on commit 1d74bdb

Please sign in to comment.