Integration of Django with dramatiq-pg
Project description
dramatiq-pg integration for django
Installation
Install with pip
$ pip install django-dramatiq-pg
Add to your INSTALLED_APPS list in settings.py
INSTALLED_APPS = [ ... 'django_dramatiq_pg', ]
Create a Registry, and register your tasks
from django_dramatiq_pg.registry import Registry tasks = Registry() @tasks.actor def mytask(): ...
Configure
DRAMATIQ_BROKER = { "OPTIONS": { "url": "postgres:///mydb", }, "MIDDLEWARE": [ "dramatiq.middleware.TimeLimit", "dramatiq.middleware.Callbacks", "dramatiq.middleware.Retries", ], } DRAMATIC_REGISTRY = 'myapp.registry.tasks'
Start the worker process:
$ dramatiq django_dramatiq_pg.worker
This worker module will auto-discover any module called ‘actors’ in INSTALLED_APPS.
Registry
In a typical dramatiq application, the Broker is configured before any tasks are registered. However, as Django is in control of the intialisation sequence, there is an issue of ordering; the actor decorator assumes the broker is already configured.
To resolve this, django_dramatiq_pg provides a Registry for your tasks, which is then bound to the Broker when Django initialises.
In your code, declare a Registry instance, and use its .actor method to decorate your task functions. Then tell django_dramatiq_pg to use your registry with the DRAMATIQ_REGISTRY setting.
If you do not specify one, django_dramatiq_pg will create one on start.
The registry can be accessed as the .registry attribute on the django_dramatiq_pg App instance.
Settings
- DRAMATIQ_BROKER
A dict of options to pass when instantiating the broker.
- DRAMATIC_BROKER[‘OPTIONS’]
Arguments to pass to the Broker.
- DRAMATIC_BROKER[‘MIDDLEWARE’]
A list of middleware classes to be passed to the broker.
These can either be import strings, or instances.
- DRAMATIQ_ENCODER
Default: None
Import path for encoder class.
- DRAMATIQ_ACTORS_MODULE
Default: ‘actors’
Name of module use to auto-discover actors in INSTALLED_APPS.
DRAMATIQ_REGISTRY
Import path for the task Registry instance.
This should refer to an instance of django_dramatiq_pg.registry.Registry.
This resolves the chicken/egg problem of declaring tasks before the broker is configured.
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
Built Distribution
File details
Details for the file django-dramatiq-pg-1.1.0.tar.gz
.
File metadata
- Download URL: django-dramatiq-pg-1.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e2dd54fd386429aa67ff81454ab5d4a7fa3f44f8cc8ae4a524b54dcb8be8d7c |
|
MD5 | 005cab3fd97bd06161f333a23c9a37e5 |
|
BLAKE2b-256 | 24b1fb67c9fc93f5ad128c2f141bfd5b20a9359f66e80af9b96406a687d1fa12 |
Provenance
File details
Details for the file django_dramatiq_pg-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_dramatiq_pg-1.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88eff3def902577205a7fbf7bea92efa7c13f6434cb2a095de61a000969189b7 |
|
MD5 | 7a24d57c7bdee0614004a05def35b196 |
|
BLAKE2b-256 | a2319e5c96fec7cc96b6ab64f8efd0fd1b14883ccc87fc46092a26c06d24a8e3 |