-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from __future__ import absolute_import | ||
|
||
import os | ||
|
||
from celery import Celery | ||
|
||
# set the default Django settings module for the 'celery' program. | ||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_kala.settings') | ||
|
||
from django.conf import settings # noqa | ||
|
||
app = Celery('django_kala') | ||
|
||
# Using a string here means the worker will not have to | ||
# pickle the object when using Windows. | ||
app.config_from_object('django.conf:settings', namespace='CELERY') | ||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from .functions import get_env_variable | ||
|
||
# Celery Configuration | ||
DEPLOYMENT_ENVIRONMENT = get_env_variable('DEPLOYMENT_ENVIRONMENT') | ||
if DEPLOYMENT_ENVIRONMENT == 'production': | ||
# If we are in production, use SQS | ||
AWS_REGION = get_env_variable('AWS_REGION', default='us-west-2') | ||
CELERY_BROKER_URL = 'sqs://@' | ||
CELERY_BROKER_TRANSPORT_OPTIONS = {'region': AWS_REGION} | ||
CELERY_SEND_TASK_ERROR_EMAILS = True | ||
|
||
# The global default rate limit for tasks. The default is no rate limit. | ||
# http://docs.celeryproject.org/en/latest/configuration.html#celery-default-rate-limit | ||
CELERY_DEFAULT_RATE_LIMIT = '1/s' | ||
|
||
CELERY_ACCEPT_CONTENT = ['pickle'] | ||
CELERY_TASK_SERIALIZER = 'pickle' | ||
|
||
# How many messages to prefetch at a time; default is 4 | ||
# http://docs.celeryproject.org/en/latest/configuration.html#celeryd-prefetch-multiplier | ||
CELERYD_PREFETCH_MULTIPLIER = 1 | ||
|
||
# Task messages will be retried in the case of connection loss or other | ||
# connection errors | ||
# http://docs.celeryproject.org/en/latest/configuration.html#celery-task-publish-retry | ||
CELERY_TASK_PUBLISH_RETRY = True | ||
|
||
# Defines the default policy when retrying publishing a task message in the | ||
# case of connection loss or other connection errors | ||
# http://docs.celeryproject.org/en/latest/configuration.html#celery-task-publish-retry-policy | ||
CELERY_TASK_PUBLISH_RETRY_POLICY = { | ||
'max_retries': 3, | ||
} | ||
|
||
# Disabling rate limits altogether is recommended if you don't have any tasks | ||
# using them. | ||
# http://docs.celeryproject.org/en/latest/userguide/tasks.html#disable-rate-limits-if-they-re-not-used | ||
CELERY_DISABLE_RATE_LIMITS = True | ||
|
||
# Late ack means the task messages will be acknowledged after the task has been | ||
# executed, not just before, which is the default behavior. | ||
# http://docs.celeryproject.org/en/latest/configuration.html#celery-acks-late | ||
CELERY_ACKS_LATE = True |