繁体   English   中英

Celery 任务未在 Flask 应用程序上运行

[英]Celery task not running on Flask application

我在我的 Flask 应用程序上设置了 Celery,如下所示:

主文件

app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost:6379/0'

# Initialize Celery
celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])

@celery.task()
def test():
    print('hello')
    
@app.route('/')
def index():
    test.delay()
    return render_template('index.html', title='Home')

Then i started a redis server and Celery using py -3.8 -m celery -A app.main.celery worker Both started successfully, the problem is that the Celery tasks are not executing. 我没有收到任何错误,我的 flask 应用程序只会在加载时卡住。 谁能帮我解决这个问题?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM