https://github.com/devforth/django-runapscheduler
https://github.com/devforth/django-runapscheduler
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devforth/django-runapscheduler
- Owner: devforth
- Created: 2021-03-04T13:31:36.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T15:48:11.000Z (over 2 years ago)
- Last Synced: 2025-01-08T07:48:54.754Z (6 months ago)
- Language: Python
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Django Run APScheduler Command
Django Run APScheduler Command is a command that simplifies management of scheduler for django apps and moves those tasks to a separate django process, so you can run heavy tas without worrying of django app stalling.To use the command firstly you need to create scheduler.py file inside your app and attach `runapscheduler.scheduled_job` decorator to any function.
`runapscheduler.scheduled_job` decorator accepts the same parameters as `APSceduler`'s [scheduled_job](https://apscheduler.readthedocs.io/en/stable/modules/schedulers/base.html#apscheduler.schedulers.base.BaseScheduler.scheduled_job) decorator.
Also it's possible to pass some options to schedulers. To do add `RUNAPSCHEDULER_OPTIONS` dictionary to `setting.py`.
First key must be a name of scheduler and the value of that key must be a dict filled as in [Method 2](https://apscheduler.readthedocs.io/en/stable/userguide.html#configuring-the-scheduler) in APScheduler documentation.
Example:
```
RUNAPSCHEDULER_OPTIONS = {
'BackgroundScheduler': {
'apscheduler.jobstores.default': {
'type': 'sqlalchemy',
'url': 'sqlite:///jobs.sqlite'
},
'apscheduler.executors.default': {
'class': 'apscheduler.executors.pool:ThreadPoolExecutor',
'max_workers': '20'
},
'apscheduler.job_defaults.coalesce': 'false',
'apscheduler.job_defaults.max_instances': '3',
'apscheduler.timezone': 'UTC',
}
}
```