Files
along_django/utils/celery_guard.py

14 lines
456 B
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 任务安全闸:生产环境仅允许「新订单服务号广播」任务执行。
"""
from django.conf import settings
_DISABLED_MSG = 'CELERY_ONLY_ORDER_BROADCAST非新订单广播任务已禁止执行'
def celery_non_broadcast_blocked():
"""若当前禁止非广播任务,返回说明字符串;否则返回 None。"""
if getattr(settings, 'CELERY_ONLY_ORDER_BROADCAST', True):
return _DISABLED_MSG
return None