Skip to main content

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

  1. Install the library using pip install django_schedulermanager

  2. Add django_schedulermanager.apps.DjangoSchedulerManagerConfig to your INSTALLED_APPS

  3. Write your job code in a module named ‘jobs’ (Remember to insert the app in the INSTALLED_APPS list)

  4. Import the schedulable annotation: from django_schedulermanager.decorators import schedulable

  5. 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’

Now you can schedule and unschedule your jobs using python manage.py schedulejob <id> and python manage.py unschedulejob <id>! Call those in your init script and your jobs should schedule (and unschedule) automatically

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

Metadata

Release files for django_schedulermanager 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django_schedulermanager 1.0.1
File Size Uploaded
django_schedulermanager-1.0.1.tar.gz 4.6 kB Details

Release files / django_schedulermanager-1.0.1.tar.gz

Download URL django_schedulermanager-1.0.1.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3889fd4af6ead8d9b925977a8f40580702a09d72bcc4a56e5b3f33fdd4304133
BLAKE2b-256 checksum
How to use checksums
ada5448ff27910e8ff542adf67acfa68a30b02f242d7f450733842b2760e401d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page