nankjune
2019-07-15 11:56
tasks.py :
import time from celery import Celery broker = 'redis://:123456@localhost:6379/1' backend= 'redis://:123456@localhost:6379/2' #存储结果 app = Celery('my_task', broker = broker, backend=backend ) @app.task def add(x,y): print('enter call func......') time.sleep(4) return x+y
app.py
if __name__ == '__main__': print('start task...') result = add.delay(2,8) print("end task...") print result
需要主动执行app文件
Python 异步任务队列 Celery 使用
10837 学习 · 43 问题
相似问题