An extension for django and huey that supports multi queue management
Project description
django-huey
This package is an extension of huey contrib djhuey package that allows users to manage multiple queues.
Compatible versions
Package | Version |
---|---|
Django | 2.2 |
Django | 3.1 |
Django | 3.2 |
huey | 2.3 |
Installation
Using pip package manager run:
pip install django-huey
Note: use a virtualenv to isolate your dependencies.
Then, in your settings.py file add django_huey to the INSTALLED_APPS:
INSTALLED_APPS = [
...
'django_huey',
]
Configuration
In settings.py you must add the DJANGO_HUEY setting:
DJANGO_HUEY = {
'default': 'first', #this name must match with any of the queues defined below.
'queues': {
'first': {#this name will be used in decorators below
'huey_class': 'huey.RedisHuey',
'name': 'first_tasks',
'consumer': {
'workers': 2,
'worker_type': 'thread',
},
},
'emails': {#this name will be used in decorators below
'huey_class': 'huey.RedisHuey',
'name': 'emails_tasks',
'consumer': {
'workers': 5,
'worker_type': 'thread',
},
}
}
}
Usage
Now you will be able to run multiple queues using:
python manage.py djangohuey --queue first
python manage.py djangohuey --queue emails
Each queue must be run in a different terminal.
If you defined a default queue, you can just run:
python manage.py djangohuey
And the default queue will be used.
Configuring tasks
You can use usual huey decorators to register tasks, but they must be imported from django_huey as shown below:
from django_huey import db_task, task
@db_task(queue='first')
def some_func():
# perform some db task
@task(queue='emails')
def send_mails():
# send some emails
All the args and kwargs defined in huey decorators should work in the same way, if not, let us know.
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
Hashes for django_huey-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abd1620dfa15e3725e57356806088cccb0a1f53abe63f4e11a35c7e2ae34782f |
|
MD5 | 48dacd0d17a99a457df2e83e8c75bddf |
|
BLAKE2b-256 | 1dffe0e501758703ea3cfe8d1770031392b776ee023a8c01c7b2f90eafff6e0e |