celery初级教程(三)
来源:互联网 发布:mac中取消隐藏文件 编辑:程序博客网 时间:2024/05/24 02:57
在项目中如何使用celery?首先创建python项目,我的项目目录结构为:
TestCelery/
├── proj │
├── celeryconfig.py │
├── celery.py │
├── init.py │
└── tasks.py
└── test.py
celery.py内容如下:
from celery import Celery# 创建celery实例app = Celery('demo')app.config_from_object('proj.celeryconfig')# 自动搜索任务app.autodiscover_tasks(['proj'])celeryconfig.p模块内容如下:
BROKER_URL = 'redis://:332572@127.0.0.1:6379/1'CELERY_RESULT_BACKEND = 'redis://:332572@127.0.0.1:6379/2'tasks.py模块内容如下:
from proj.celery import app as celery_app# 创建任务函数@celery_app.taskdef my_task1(): print("任务函数(my_task1)正在执行....")@celery_app.taskdef my_task2(): print("任务函数(my_task2)正在执行....")@celery_app.taskdef my_task3(): print("任务函数(my_task3)正在执行....")启动worker:
celery -A proj worker -l info
键入ctrl+c可关闭worker.
阅读全文
0 0
- celery初级教程(三)
- celery初级教程(一)
- celery初级教程(二)
- celery初级教程(四)
- celery初级教程(五)
- celery初级教程(六)
- celery初级教程(七)
- django中使用celery(三)
- Android程序开发初级教程(三)
- Android程序开发初级教程(三)
- Celery
- celery
- celery
- Celery
- Celery源码分析(三)---------Blueprint
- 初级教程
- ExtJS初级教程之ExtJS Tree(三)
- ExtJS初级教程之ExtJS Grid(三)
- eclipse关于struts2整合hibernate遇到的导入包的问题
- log4net的运用示例
- poj3648 Wedding 2-sat
- 历届试题 PREV-2 打印十字图
- js数组去重
- celery初级教程(三)
- 文章标题
- 使用pyinstaller 打包程序后,运行Failed to execute script MainPage 报错,解决办法
- 部署及更新应用
- 17ACM Qingdao 1003 The Dominator of Strings
- LeetCode#5 Longest Palindromic Substring (week3)
- opencv3+opencv_contrib 安装ubuntu16.04
- 欢迎使用CSDN-markdown编辑器
- Android利用LayerDrawable实现各大App应用市场上选项卡切换效果