celery django集成
需要再django 中集成celery
- 第一种直接安装独立部署
django==3.2
celery==5.0.5
django-celery-beat==2.2.0
django-celery-results==2.0.1
flower==1.2.0)
单独文件中配置
查看某个包的 所有版本
- pip install xxx==
第二种 djcelery
- 使用 python manage.py help
[djcelery]
celery
celerybeat
celerycam
celeryd
celeryd_detach
celeryd_multi
celerymon
djcelerymon
- 在settings 里面配置
import djcelery
djcelery.setup_loader()
CELERY_QUEUES = {
'beat_tasks': {
'exchange': 'beat_tasks',
'exchange_type': 'direct',
'binding_key': 'beat_tasks'
},
'work_queue': {
'exchange': 'work_queue',
'exchange_type': 'direct',
'binding_key': 'work_queue'
}
}
CELERY_DEFAULT_QUEUE = 'work_queue'
CELERY_IMPORTS = (
'app_celery.tasks',
)
CELERY_TIMEZONE = 'Asia/Shanghai'
TIME_ZONE = 'Asia/Shanghai'
CELERY_ACKS_LATE = True
CELERYD_FORCE_EXECV = True
CELERYD_CONCURRENCY = 4
CELERYD_MAX_TASKS_PRE_CHILD = 100
CELERYD_TASK_TIME_LIMIT = 12 * 30
BROKER_BACKEND = 'redis'
BROKER_URL = 'redis://192.168.1.76:6379/1'
CELERY_RESULT_BACKEND = 'redis://192.168.1.76:6379/2'
CELERY_TIMEZONE = "Asia/Shanghai"
CELERY_BROKER_URL = 'redis://:@192.168.1.76:6379/0'
CELERY_RESULT_BACKEND = 'redis://:@192.168.1.76:6379/0'
CELERY_ACCEPT_CONTENT = ['json', ]
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_MAX_TASKS_PER_CHILD = 200
CELERYD_CONCURRENCY = 2
CELERY_TASK_TIME_LIMIT = 60 * 60
本文来自博客园,作者:vx_guanchaoguo0,转载请注明原文链接:https://www.cnblogs.com/guanchaoguo/p/17192312.html