You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
691 B
27 lines
691 B
import os |
|
from celery import Celery |
|
from celery.schedules import crontab |
|
from django.conf import settings |
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dingxin_toolbox_drf.settings') |
|
|
|
# 创建 Celery实例 |
|
app = Celery('dingxin_toolbox_drf') |
|
|
|
# 加载配置文件中的Celery配置 |
|
app.config_from_object('django.conf:settings', namespace='CELERY') |
|
|
|
# 自动发现并添加任务 |
|
app.autodiscover_tasks() |
|
|
|
# 强制单实例运行 |
|
app.conf.worker_prefetch_multiplier=1 |
|
app.conf.task_acks_late=True |
|
|
|
# app.conf.beat_schedule = { |
|
# 'update_client_task': { |
|
# 'task': 'update.tasks.update_client', |
|
# # 'schedule': crontab(hour='*'), |
|
# 'schedule': 30, |
|
# }, |
|
# }
|
|
|