Celery定时任务
目录树 celery_app | | - - __init__ . py # celery应用文件 | | - - celeryconfig . py # celery应用配置文件 | | - - task1 . py # 任务文件1 | | - - task2 . py # 任务文件2 文件内容 __init__.py 文件内容如下: from celery import Celery app = Celery ( 'demo' ) # 通过celery实例加载配置模块 app . config_from_object ( 'celery_app.celeryconfig' ) celeryconfig.py 文件内容如下: from datetime import timedelta from celery . schedules import crontab BROKER_URL = 'redis://localhost:6379/1' CELERY_RESULT_BACKEND = 'redis://localhost:6379/2' # 是否丢弃运行结果(丢弃结果会提升效率) # CELERY_IGNORE_RESULT = True # 指定时区, 默认是UTC时间,由于ceery对时区支持不是很好,所以我选择不指定 # CELERY_TIMEZONE = 'Asia