Add Celery Priorities

This commit is contained in:
Aaron Kable
2020-03-26 02:20:02 +00:00
committed by Ariel Rin
parent 32e0621b0a
commit 8861ec0a61
5 changed files with 31 additions and 10 deletions

View File

@@ -11,6 +11,15 @@ app = Celery('devauth')
# Using a string here means the worker don't have to serialize
# the configuration object to child processes.
app.config_from_object('django.conf:settings')
# setup priorities ( 0 Highest, 9 Lowest )
app.conf.broker_transport_options = {
'priority_steps': list(range(10)), # setup que to have 10 steps
'queue_order_strategy': 'priority', # setup que to use prio sorting
}
app.conf.task_default_priority = 5 # anything called with the task.delay() will be given normal priority (5)
app.conf.worker_prefetch_multiplier = 1 # only prefetch single tasks at a time on the workers so that prio tasks happen
app.conf.ONCE = {
'backend': 'allianceauth.services.tasks.DjangoBackend',
'settings': {}