【django-celery】异步任务管理器---celery
因为superviser不支持python3,而网上关于celery后台运行的说明大都使用superviser,所以对于python3用户celery后台运行便成为了一个问题。再没废话,直接上代码。 环境说明: python3.6 django2.0.5 我们使用redis的作为celery任务队列,有一个合成包可以直接安装两者一起使用需要的安装包 直接在终端键入 pip install celery-with-redis 就可以安装需要的依赖包了 构建项目过程略过,直接开始进行celery配置 一、celery配置。 我们的项目名称为myproject,首先setting配置,添加 # celery settings # celery中间人 redis://redis服务所在的ip地址:端口/数据库号 BROKER_URL = ' redis://localhost:6379/3 ' # celery结果返回,可用于跟踪结果 CELERY_RESULT_BACKEND = ' redis://localhost:6379/3 ' # celery内容等消息的格式设置 CELERY_ACCEPT_CONTENT = [ ' application/json ' , ] CELERY_TASK_SERIALIZER = ' json ' CELERY_RESULT