Files
Django/a_long_dianjing/celery.py
XingQue 193a82930e chore: Beat仅保留冻结解冻+可控自动结算,并加固关开关立即停结
自动结算结单前再校验俱乐部开关与 SettlementTime>=开启时间;关开关仍清 eligible。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 03:17:01 +08:00

62 lines
2.0 KiB
Python
Raw Permalink 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 定时任务主配置
业务约定2026-07Beat 只跑两条
1) 资金冻结到期解冻
2) 可控订单自动结算
其余榜单/清零类任务保留代码但不进 beat_schedule不会定时执行。
"""
import os
from celery import Celery
from celery.schedules import crontab
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'a_long_dianjing.settings')
app = Celery('a_long_dianjing')
app.config_from_object('django.conf:settings', namespace='CELERY')
# 仅自动发现仍可能被调用的任务模块;旧超时结算 orders.tasks 永不加载
app.autodiscover_tasks(['jituan.tasks', 'users.tasks', 'users.ranking_tasks', 'config.tasks'])
# ========== Beat只保留这两个 ==========
app.conf.beat_schedule = {
# 资金冻结到期解冻(俱乐部未开冻结 / 无到期单 → 空跑)
'scan_fund_freeze_due': {
'task': 'jituan.tasks.scan_fund_freeze_due',
'schedule': crontab(minute='*/5'),
'options': {
'queue': 'periodic_tasks',
'priority': 4,
},
},
# 可控自动结算(俱乐部后台开关关 → 空跑;只处理 AutoSettleEligible 新单)
'scan_order_auto_settle_due': {
'task': 'jituan.tasks.scan_order_auto_settle_due',
'schedule': crontab(minute='*/5'),
'options': {
'queue': 'periodic_tasks',
'priority': 4,
},
},
}
app.conf.timezone = 'Asia/Shanghai'
app.conf.enable_utc = True
app.conf.task_routes = {
'jituan.tasks.*': {'queue': 'periodic_tasks'},
'users.tasks.*': {'queue': 'periodic_tasks'},
'config.tasks.*': {'queue': 'periodic_tasks'},
}
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 = 4
app.conf.worker_prefetch_multiplier = 1
app.conf.task_acks_late = True
app.conf.worker_disable_rate_limits = True
app.conf.result_expires = 3600