Skip to content

Commit c5753a5

Browse files
humitosagjohnson
authored andcommitted
Ability to override the creation of the Celery App (readthedocs#3623)
* Ability to override the creation of the Celery App * Revert "Ability to override the creation of the Celery App" This reverts commit d21649c. * Use simple settings to reuse the Celery App * Fix Django settings when running tests
1 parent 6317e06 commit c5753a5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

readthedocs/settings/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def USE_PROMOS(self): # noqa
231231
USE_L10N = True
232232

233233
# Celery
234+
CELERY_APP_NAME = 'readthedocs'
234235
CELERY_ALWAYS_EAGER = True
235236
CELERYD_TASK_TIME_LIMIT = 60 * 60 # 60 minutes
236237
CELERY_SEND_TASK_ERROR_EMAILS = False

readthedocs/worker.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1+
# -*- coding: utf-8 -*-
12
"""Celery worker application instantiation"""
23

34
from __future__ import absolute_import, unicode_literals
45

56
import os
67

78
from celery import Celery
9+
from django.conf import settings
810

911

1012
def create_application():
11-
"""Create a Celery application using Django settings"""
12-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'readthedocs.settings.dev')
13-
application = Celery('readthedocs')
13+
"""Create a Celery application using Django settings."""
14+
os.environ.setdefault(
15+
'DJANGO_SETTINGS_MODULE',
16+
'readthedocs.settings.dev',
17+
)
18+
19+
application = Celery(settings.CELERY_APP_NAME)
1420
application.config_from_object('django.conf:settings')
1521
application.autodiscover_tasks(None)
1622
return application

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ python =
1010
[testenv]
1111
setenv =
1212
PYTHONPATH={toxinidir}/readthedocs:{toxinidir}
13-
DJANGO_SETTINGS_MODULE=settings.test
13+
DJANGO_SETTINGS_MODULE=readthedocs.settings.test
1414
LANG=C
1515
DJANGO_SETTINGS_SKIP_LOCAL=True
1616
deps = -r{toxinidir}/requirements/testing.txt

0 commit comments

Comments
 (0)