mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-03-03 19:08:15 +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
|
# Celery
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
INSTALLED_APPS += ['{{cookiecutter.project_slug}}.taskapp.celery.CeleryAppConfig']
|
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
|
# 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
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_backend
|
||||||
if CELERY_BROKER_URL == 'django://':
|
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
||||||
CELERY_RESULT_BACKEND = 'redis://'
|
|
||||||
else:
|
|
||||||
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
|
|
||||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content
|
||||||
CELERY_ACCEPT_CONTENT = ['json']
|
CELERY_ACCEPT_CONTENT = ['json']
|
||||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_serializer
|
||||||
CELERY_TASK_SERIALIZER = 'json'
|
CELERY_TASK_SERIALIZER = 'json'
|
||||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_serializer
|
||||||
CELERY_RESULT_SERIALIZER = 'json'
|
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 %}
|
{%- endif %}
|
||||||
# django-allauth
|
# django-allauth
|
||||||
|
|
|
@ -76,8 +76,10 @@ INSTALLED_APPS += ['django_extensions'] # noqa F405
|
||||||
|
|
||||||
# Celery
|
# Celery
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-task_always_eager
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-always-eager
|
||||||
CELERY_ALWAYS_EAGER = True
|
CELERY_TASK_ALWAYS_EAGER = True
|
||||||
|
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#task-eager-propagates
|
||||||
|
CELERY_TASK_EAGER_PROPAGATES = True
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
# Your stuff...
|
# Your stuff...
|
||||||
|
|
Loading…
Reference in New Issue
Block a user