Files
along_django/a_long_dianjing/celery.py

41 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
阿龙电竞 - Celery 配置(仅新订单服务号广播)
严禁 autodiscover / beat 加载结算、清零、排行榜等任务。
生产只启动 broadcast 队列 worker不要启动 celery beat。
"""
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'a_long_dianjing.settings')
app = Celery('a_long_dianjing')
app.config_from_object('django.conf:settings', namespace='CELERY')
# 只注册新订单服务号广播任务dingdan.tongzhi_tasks.dingdan_guangbo
app.autodiscover_tasks(['dingdan.tongzhi_tasks'])
# 禁止 Beat 周期性任务(清零、排行榜、自动结算补偿等一律不调度)
app.conf.beat_schedule = {}
app.conf.timezone = 'Asia/Shanghai'
app.conf.enable_utc = True
# 仅广播任务路由到 broadcast 队列
app.conf.task_routes = {
'dingdan.tongzhi_tasks.dingdan_guangbo': {'queue': 'broadcast'},
}
app.conf.accept_content = ['json']
app.conf.task_serializer = 'json'
app.conf.result_serializer = 'json'
app.conf.task_time_limit = 300
app.conf.task_soft_time_limit = 240
app.conf.worker_concurrency = 2
app.conf.worker_prefetch_multiplier = 1
app.conf.task_acks_late = True
app.conf.worker_disable_rate_limits = True
app.conf.result_expires = 3600