app.conf.update( task_serializer='json', accept_content=['json'], result_serializer='json', timezone='Europe/Oslo', enable_utc=True, )
task_serializer = 'json' result_serializer = 'json' accept_content = ['json'] timezone = 'Europe/Oslo' enable_utc = True
BROKER_URL = 'amqp://username:passwd@host:port/虚拟主机名'
CELERY_RESULT_BACKEND = 'redis://username:passwd@host:port/db'
CELERY_TASK_SERIALIZER = 'msgpack'
CELERY_RESULT_SERIALIZER = 'msgpack'
CELERY_TASK_RESULT_EXPIRES = 60 * 20
CELERY_ACCEPT_CONTENT = ["msgpack"]
CELERY_ACKS_LATE = True
CELERY_MESSAGE_COMPRESSION = 'zlib'
CELERYD_TASK_TIME_LIMIT = 5 # 在5s内完成任务,否则执行该任务的worker将被杀死,任务移交给父进程
CELERYD_CONCURRENCY = 4
CELERYD_PREFETCH_MULTIPLIER = 4
CELERYD_MAX_TASKS_PER_CHILD = 40
CELERY_DEFAULT_QUEUE = "default"
CELERY_QUEUES = { "default": { # 这是上面指定的默认队列 "exchange": "default", "exchange_type": "direct", "routing_key": "default" }, "topicqueue": { # 这是一个topic队列 凡是topictest开头的routing key都会被放到这个队列 "routing_key": "topic.#", "exchange": "topic_exchange", "exchange_type": "topic", }, "task_eeg": { # 设置扇形交换机 "exchange": "tasks", "exchange_type": "fanout", "binding_key": "tasks", }, }