Skip to content

Commit a60b2c1

Browse files
committed
Setting CELERY_RESULT_BACKEND to use djceleryand other little things.
1 parent 8f02143 commit a60b2c1

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
*.log
44
*.pid
55
*.db
6+
proj/*.log
7+
demoapp/*.log
8+
proj/settings_secret.py

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
### Code Playground at C9 - https://ide.c9.io/mikeumus/celery-django-example
22

3+
##### Celery Processes Notes
4+
- Celery + Django Project Template by @dvl: https://github.com/dvl/celerytest
5+
- Thanks @dvl :)
6+
- and celery docs django template: https://github.com/celery/celery/tree/3.1/examples/django
7+
- Retry Policy
8+
- http://docs.celeryproject.org/en/master/userguide/calling.html#retry-policy
9+
- Starting tasks in the background with `celery multi`: http://docs.celeryproject.org/en/master/getting-started/next-steps.html?highlight=multi#in-the-background
10+
- `celery multi start w1 -A proj -l info`
11+
- Starting a process locally in the terminal: `celery -A proj worker -l info`
12+
313
_ _ _
414

515

proj/settings.py

+11-14
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
# for relative imports by default.
66

77
# Celery settings
8-
98
import djcelery
109
djcelery.setup_loader()
1110

11+
# http://fearofcode.github.io/blog/2013/01/15/how-to-scrub-sensitive-information-from-django-settings-dot-py-files/
12+
from proj.settings_secret import *
13+
1214
# BROKER_URL = 'amqp://guest:guest@localhost//'
1315
BROKER_URL = 'django://'
1416

@@ -17,6 +19,7 @@
1719
CELERY_ACCEPT_CONTENT = ['json']
1820
CELERY_TASK_SERIALIZER = 'json'
1921
CELERY_RESULT_SERIALIZER = 'json'
22+
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend' # http://docs.celeryproject.org/en/master/django/first-steps-with-django.html#using-the-django-orm-cache-as-a-result-backend
2023

2124
# Django settings for proj project.
2225

@@ -47,7 +50,7 @@
4750
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
4851
# although not all choices may be available on all operating systems.
4952
# In a Windows environment this must be set to your system time zone.
50-
TIME_ZONE = 'America/Chicago'
53+
TIME_ZONE = 'US/Eastern'
5154

5255
# Language code for this installation. All choices can be found here:
5356
# http://www.i18nguy.com/unicode/language-identifiers.html
@@ -99,9 +102,6 @@
99102
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
100103
)
101104

102-
# Make this unique, and don't share it with anybody.
103-
SECRET_KEY = 'x2$s&0z2xehpnt_99i8q3)4)t*5q@+n(+6jrqz4@rt%a8fdf+!'
104-
105105
# List of callables that know how to import templates from various sources.
106106
TEMPLATE_LOADERS = (
107107
'django.template.loaders.filesystem.Loader',
@@ -114,8 +114,8 @@
114114
'django.middleware.csrf.CsrfViewMiddleware',
115115
'django.contrib.auth.middleware.AuthenticationMiddleware',
116116
'django.contrib.messages.middleware.MessageMiddleware',
117-
# Uncomment the next line for simple clickjacking protection:
118-
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
117+
# simple clickjacking protection:
118+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
119119
)
120120

121121
ROOT_URLCONF = 'proj.urls'
@@ -137,15 +137,12 @@
137137
'django.contrib.sites',
138138
'django.contrib.messages',
139139
'django.contrib.staticfiles',
140-
'django.contrib.admin',
141-
'kombu.transport.django',
142-
# 'kombu.transport.django.KombuAppConfig',
140+
#'kombu.transport.django',
141+
'kombu.transport.django.KombuAppConfig',
143142
'djcelery',
144143
'demoapp',
145-
# Uncomment the next line to enable the admin:
146-
# 'django.contrib.admin',
147-
# Uncomment the next line to enable admin documentation:
148-
# 'django.contrib.admindocs',
144+
'django.contrib.admin', # https://docs.djangoproject.com/en/1.8/ref/contrib/admin/
145+
# 'django.contrib.admindocs', # https://docs.djangoproject.com/en/1.8/ref/contrib/admin/admindocs/
149146
)
150147

151148
# A sample logging configuration. The only tangible logging

proj/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
# url(r'^blog/', include('blog.urls')),
88

99
url(r'^admin/', include(admin.site.urls)),
10+
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # https://docs.djangoproject.com/en/1.8/ref/contrib/admin/admindocs/#overview
1011
)

0 commit comments

Comments
 (0)