Skip to main content

A Django app for running periodic or one off jobs.

Project description

Simple async jobs is a Django app that provides you a simple way for running periodic and one off jobs using django management commands.

Installation

pip install django-simple-async-jobs

Quick start

  1. Add “simple_jobs” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'simple_jobs',
    ]
  2. Setup the following settings:

    JOB_POLLER_TIMEOUT_BEFORE_KILLED = 60
    
    DEFAULT_LOGGER_NAME = "jobs"
    PERIODIC_JOBS_LOGGER_NAME = "periodic_jobs"
    ONE_OFF_JOBS_LOGGER_NAME = "one_off_jobs"
    
    DEFAULT_MAX_ONE_OFF_JOBS_RUNS_PER_LIFE = 10
    DEFAULT_MAX_PERIODIC_JOBS_RUNS_PER_LIFE = 50
    
    DEFAULT_MAX_JOB_RETRIES = 6
    DEFAULT_JOB_RETRY_SECONDS_INTERVAL = 900
  3. Run python manage.py migrate to create the jobs models.

  4. Start the development server and visit http://127.0.0.1:8000/admin/ to create a Job (you’ll need the Admin app enabled).

  5. Run the python manage.py one_off_job_poller or python manage.py periodic_job_poller.

It’s recommended to use one of the django management commands as CMD for docker container in docker-compose config with parameter restart=always. Example:

worker-one-off-jobs:
  build: .
  container_name: "worker-one-off"
  restart: "always"
  command: python manage.py one_off_job_poller

The lifetime of container consists of the following:

1) retrieve jobs
2) execute jobs until the limit is hit
3) sleep for time specified in settings
4) exit

Once container is dead it will be launched again by docker-compose.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-simple-async-jobs-0.1.4.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file django-simple-async-jobs-0.1.4.tar.gz.

File metadata

File hashes

Hashes for django-simple-async-jobs-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8581a9b39a3b4ae0c35449dc4ae3ffe7aeffe4fb1f4eb16a3f784129fa962378
MD5 96a01712872cf32f06bc9bb33fbd0276
BLAKE2b-256 ceaac7a8c8d53975a521adb5a579f6c7d484abd1c3e4ec5cc8de3f6c1292b1c9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page