20 lines
490 B
Python
20 lines
490 B
Python
from __future__ import absolute_import, unicode_literals
|
|
import os
|
|
from celery import Celery
|
|
|
|
# 设置 Django 的 settings 模块
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'educheck.settings')
|
|
|
|
# 创建 Celery 应用
|
|
app = Celery('educheck')
|
|
|
|
# 使用 Django 配置中的 Celery 配置
|
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
|
|
|
# celery.py
|
|
app.conf.broker_connection_retry_on_startup = True
|
|
|
|
|
|
# 自动发现所有的 tasks.py 文件
|
|
app.autodiscover_tasks()
|