Pycharm中配置Celery启动

Pycharm中配置Celery启动

前置条件

目录结构
----FerDemo
--------celery_demo
------------tasks.py

tasks.py文件代码

import sys
import time
from celery import Celery

app = Celery('demo',
             backend='redis://:[email protected]/0',
             broker='redis://:[email protected]/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配置
Pycharm中配置Celery启动_第1张图片

执行就行,实际上就是在项目目录FerDemo下执行了 celery - A celery_demo.tasks worker -l INFO

你可能感兴趣的:(python,IDEA,日常踩坑,pycharm,python)