django celery 异步

一、环境

Package                  Version
------------------------ -------------------
python                   3.6
amqp                     1.4.9
anyjson                  0.3.3
baidu-aip                2.2.18.0
billiard                 3.3.0.23
celery                   3.1.26.post2
certifi                  2020.6.20
chardet                  3.0.4
Django                   2.0.7
django-celery            3.2.2
django-celery-with-redis 3.0
idna                     2.10
kombu                    3.0.37
lxml                     4.5.2
numpy                    1.19.1
pandas                   1.1.0
phone                    0.4.2
pip                      20.1.1
pymongo                  3.9.0
PyMySQL                  0.10.0
python-dateutil          2.8.1
pytz                     2018.5
redis                    2.10.6
requests                 2.24.0
setuptools               49.2.0.post20200714
six                      1.15.0
urllib3                  1.25.10
wheel                    0.34.2
wincertstore             0.2

二、配置

1、setting.py文件

import djcelery
# 配置 celery
djcelery.setup_loader()
# 密码的redis链接配置 BROKER_URL="redis://:password@127.0.0.1:6379/3"
BROKER_URL = "redis://:password@127.0.0.1:6027/1"
CELERY_RESULT_BACKEND = BROKER_URL
# celery 定时任务
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
CELERY_TIMEZONE = 'Asia/Shanghai'

# 添加 app
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'djcelery',
    'security,
]

# 修改时区
TIME_ZONE = 'Asia/Shanghai'
USE_TZ = False

2、task

待续

3、controller

待续

posted @ 2020-08-19 16:35  市丸银  阅读(152)  评论(1编辑  收藏  举报