簡體   English   中英

錯誤:沒有這樣的選項:-b 在運行 celery 和 redis 作為消息代理時

[英]Error: No such option: -b while running celery and redis as message broker

I am having a flask app which is doing inference on a ml model and I added celery and redis as message broker to do queue based predictions

from celery import Celery

app.config.update(
CELERY_BROKER_URL='redis://localhost:6379/0',
CELERY_RESULT_BACKEND='redis://localhost:6379/0'
)
def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery


app = Flask(__name__)
CORS(app)

celery = make_celery(app)


@celery.task
response = {}
@app.route('/predict', methods=["POST", "GET"])
def predict():
    if request.method=='POST':
        solute = request.form["solute"]
        solvent = request.form["solvent"]

    else:
        solute = request.args.get("solute")
        solvent = request.args.get("solvent")

    results = predictions(solute, solvent)
    
    response["predictions"] = results[0].item()
    response["interaction_map"] = (results[1].detach().numpy()).tolist()
    return flask.jsonify({'result': response})

我已經跑了celery worker -b redis://localhost:6379 --app= main.celery -l here -b is broker 但我得到了Error: No such option: -b 我不知道我在哪里做錯了。

我在 windows WSL 中運行這個,在 vscode 中配置了 ubuntu。

我剛剛遇到了同樣的問題,然后我運行了celery ,它顯示: Usage: celery [OPTIONS] COMMAND [ARGS]...並在OPTIONS中列出-b 因此,按該順序運行celery -b redis://localhost:6379 worker將起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM