Pycharm中配置Celery启动
前置条件
目录结构
----FerDemo
--------celery_demo
------------tasks.py
tasks.py文件代码
import sys
import time
from celery import Celery
app = Celery('demo',
backend='redis://:password@127.0.0.1/0',
broker='redis://:password@127.0.0.1/1',
broker_connection_retry_on_startup=True,
)
@app.task
def add(a, b):
time.sleep(100)
return a + b
if __name__ == '__main__':
app.start(argv=sys.argv[1:])
pycharm配置
执行就行,实际上就是在项目目录FerDemo下执行了 celery - A celery_demo.tasks worker -l INFO