Skip to content

Instantly share code, notes, and snippets.

@craigderington
Created October 9, 2018 19:45
Show Gist options
  • Save craigderington/a4b2c1d011ffeb4ed3ac648052f6176b to your computer and use it in GitHub Desktop.
Save craigderington/a4b2c1d011ffeb4ed3ac648052f6176b to your computer and use it in GitHub Desktop.
Config module for Celery project
import os
from kombu import Queue, Exchange
BASEDIR = os.path.abspath(os.path.dirname(__file__))
class Config(object):
DEBUG = False
SECRET_KEY = os.urandom(32)
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', SQLITE_DB)
CELERY_TIMEZONE = 'US/Eastern'
CELERY_BROKER_URL = 'amqp://localhost/'
CELERY_RESULT_BACKEND = 'rpc://'
# define the tasks queues
CELERY_QUEUES = (
Queue('default', Exchange('default'), routing_key='default')
)
# define the task routes
CELERY_ROUTES = {
'default': {'queue': 'default', 'routing_key': 'default'}
}
class DevelopmentConfig(Config):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
config = {
'development': DevelopmentConfig,
'production': ProductionConfig
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment