Skip to main content

robust background queue for django

Project description

install

$ pip install django-robust
INSTALLED_APPS = [
    'robust.apps.RobustConfig',
]
DB = {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
}
DATABASES = {
    'default': DB,
    'robust_ratelimit': DB, # <- same db
}

define tasks

from robust import task

@task()
def heavy_stuff(foo):
    pass

@task(tags=['service1'])
def talk_to_external_service():
    pass

@task(bind=True, retries=3)
def retry_me(self):
    self.retry()

schedule tasks

from .tasks import heavy_stuff

heavy_stuff.delay(foo='bar')

execute tasks

$ ./manage.py robust_worker

run scheduler

standalone

$ ./manage.py robust_beat

embedded

$ ./manage.py robust_worker --beat

settings

ROBUST_RATE_LIMIT = {
    'service1': (1, timedelta(seconds=10)),  # 1/10s,
    'bar':      (20, timedelta(minutes=1)),  # 20/m
}

ROBUST_SCHEDULE = [
    (timedelta(seconds=1), 'foo.tasks.every_second'),
    (timedelta(minutes=5), 'foo.tasks.every_5_minutes'),
]

ROBUST_LOG_EVENTS = True  # log all task state changes

ROBUST_WORKER_FAILURE_TIMEOUT = 5  # wait 5 seconds when worker faces unexpected errors

ROBUST_NOTIFY_TIMEOUT = 10  # listen to postgres notify for 10 seconds, then poll database

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-robust-0.1.5.tar.gz (11.8 kB view hashes)

Uploaded Source

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