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.
25 lines
584 B
25 lines
584 B
# test_Bootstrap/celery.py
|
|
from __future__ import absolute_import, unicode_literals
|
|
|
|
import os
|
|
|
|
from celery import Celery
|
|
|
|
# 设置 Django 的设置模块为项目的设置模块
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_Bootstrap.settings')
|
|
|
|
app = Celery('test_Bootstrap')
|
|
|
|
# 使用 settings.py 中的配置
|
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
|
|
# 自动发现任务
|
|
app.autodiscover_tasks()
|
|
|
|
@app.task(bind=True)
|
|
def debug_task(self):
|
|
print(f'Request: {self.request!r}')
|
|
|
|
# 配置最大唤醒间隔
|
|
app.conf.beat_max_loop_interval = 10
|