mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-11 04:07:48 +03:00
Extend & enhance Celery configuration (#1679)
* CELERY_TASK_TIME_LIMIT * CELERY_TASK_SOFT_TIME_LIMIT * CELERY_ALWAYS_EAGER -> CELERY_TASK_ALWAYS_EAGER * CELERY_EAGER_PROPAGATES = CELERY_TASK_ALWAYS_EAGER Addresses https://github.com/pydanny/cookiecutter-django/pull/1446/files#r167238808 * CELERY_RESULT_BACKEND = CELERY_BROKER_URL always * CELERY_TIMEZONE = TIME_ZONE * CELERY_TASK_EAGER_PROPAGATES = True * Name task limit settings appropriately CELERY_TASK_TIME_LIMIT -> CELERYD_TASK_TIME_LIMIT, CELERY_TASK_SOFT_TIME_LIMIT -> CELERYD_TASK_SOFT_TIME_LIMIT
This commit is contained in:
parent
5309fbf5e7
commit
07060eaecc
|
@ -229,19 +229,25 @@ MANAGERS = ADMINS
|
|||
# Celery
|
||||
# ------------------------------------------------------------------------------
|
||||
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryAppConfig']
|
||||
if USE_TZ:
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-timezone
|
||||
CELERY_TIMEZONE = TIME_ZONE
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-broker_url
|
||||
CELERY_BROKER_URL = env('CELERY_BROKER_URL', default='django://')
|
||||
CELERY_BROKER_URL = env('CELERY_BROKER_URL')
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
|
||||
if CELERY_BROKER_URL == 'django://':
|
||||
CELERY_RESULT_BACKEND = 'redis://'
|
||||
else:
|
||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
|
||||
CELERY_ACCEPT_CONTENT = ['json']
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
|
||||
CELERY_TASK_SERIALIZER = 'json'
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
|
||||
CELERY_RESULT_SERIALIZER = 'json'
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-time-limit
|
||||
# TODO: set to whatever value is adequate in your circumstances
|
||||
CELERYD_TASK_TIME_LIMIT = 5 * 60
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-soft-time-limit
|
||||
# TODO: set to whatever value is adequate in your circumstances
|
||||
CELERYD_TASK_SOFT_TIME_LIMIT = 60
|
||||
|
||||
{%- endif %}
|
||||
# django-allauth
|
||||
|
|
|
@ -76,8 +76,10 @@ INSTALLED_APPS += ['django_extensions'] # noqa F405
|
|||
|
||||
# Celery
|
||||
# ------------------------------------------------------------------------------
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_always_eager
|
||||
CELERY_ALWAYS_EAGER = True
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-always-eager
|
||||
CELERY_TASK_ALWAYS_EAGER = True
|
||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-eager-propagates
|
||||
CELERY_TASK_EAGER_PROPAGATES = True
|
||||
|
||||
{%- endif %}
|
||||
# Your stuff...
|
||||
|
|
Loading…
Reference in New Issue
Block a user