关于烧瓶和芹菜的问题 -
init.py
from celery import Celery
from flask import Flask
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost'
app.config['CELERY_BROKER_URL'] = 'redis://localhost'
celery = Celery(app.name, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
training.py
from project import celery
training = Blueprint('training', __name__)
@training.route('/projectdetails/training', methods=["GET", "POST"])
@login_required
def start_training():
train_test.delay()
return render_template('test.html')
@celery.task()
def train_test():
# a ML training task.
我有我的 redis 服务器和我的芹菜工人 celery -A myproject.celery worker --loglevel=info
。
这是我不断收到的错误 -
[2021-04-01 17:25:11,604: ERROR/MainProcess] Process 'ForkPoolWorker-8' pid:67580 exited with 'exitcode 2'
[2021-04-01 17:25:11,619: ERROR/MainProcess] Task handler raised error: WorkerLostError('Worker exited prematurely: exitcode 2.')
Traceback (most recent call last):
File "/Users/rohankamath/Desktop/lol/env/lib/python3.7/site-packages/billiard/pool.py", line 1267, in mark_as_worker_lost
human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: exitcode 2.
尝试在 exitcode2 上搜索含义,找不到任何内容。
答案 0 :(得分:0)
当我的代码中出现一些导入错误时,我就遇到了这种情况。你可以试试不加celery运行(直接调用main函数)看看能不能运行?