A package that allows you to schedule and unschedule jobs
Project description
Creates two commands schedulejob and unschedulejob that allows you to schedule (and unschedule) background jobs.
If you have a brunch of jobs to start with your backend (e.g, if you have to update your social feed every hour) you can just write the code of the job, mark it with the schedulable decorator and the job will be schedulable with the schedulejob command.
Right now the library uses django-rq + rq-scheduler, but the dependency on django-rq is not needed and will be removed soon.
How to use
Add django_schedulermanager.apps.DjangoSchedulerManagerConfig to your INSTALLED_APPS
Write your job code in a module named ‘jobs’ (Remember to insert the app in the INSTALLED_APPS list)
Import the schedulable annotation: from django_schedulermanager.decorators import schedulable
Mark your function with schedulable. You can pass to the decorator the following parameters:
interval: The interval of the function. Required.
scheduled_time: When the function should start the first time. Required. It’s a function.
repeat: Not required, by default None which means ‘repeat always’
id: The ID of the job. It will also be the name of the job that you have to pass when using (un)schedulejob. Not required, by default None which means ‘use the name of the function’
queue: The queue to use. By default ‘default’
See also test-project directory to see an example, if you want to test the project, clone the repository and run the command make testproject, it will copy the django_schedulermanager folder (the library code) in the test-project folder
TODO
[ ] Remove dependency on django-rq
[ ] If present, read ‘queue’ from @job annotation
[ ] Add unschedulejob all to unschedule all the jobs
[ ] Add a command to remove all the scheduled jobs that don’t have a function in the jobs.py files
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django_schedulermanager-1.0.tar.gz
.
File metadata
- Download URL: django_schedulermanager-1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c3aa2957492926ec0f789e64f91deec1bca1673b94d1ccb54e8f871db0ea260 |
|
MD5 | 720852a71100919b834f4a37394d21e4 |
|
BLAKE2b-256 | 584cfa0602905ae72b14389bfb8d8724317d27c00f814ba5c1eab181f17f9654 |