当前位置 : 主页 > 编程语言 > python >

celery使用

来源:互联网 收集:自由互联 发布时间:2022-06-28
##celery_study.py from celery import Celery app=Celery('tasks',broker='amqp://guest@192.168.1.79//') @app.task def add(x,y): return x+y linux shell启动:celery -A celery_study worker --loglevel=info linux shell#cd 到celery_study.py的目录
##celery_study.py
from celery import Celery
app=Celery('tasks',broker='amqp://guest@192.168.1.79//')
@app.task
def add(x,y):
return x+y

linux shell启动:celery -A celery_study worker --loglevel=info

linux shell#cd 到celery_study.py的目录 执行python

>>from  celery_study import add

>>add.delay(3,4)

 


上一篇:python 中locals() 和 globals()
下一篇:没有了
网友评论