Python 如何在flask应用程序中运行异步任务(不在芹菜中使用Rabbit MQ)

Python 如何在flask应用程序中运行异步任务(不在芹菜中使用Rabbit MQ),python,Python,我只需要在调用路由后运行一个异步任务。任务启动后应返回响应。如果不在python中使用RabbitMQ和芹菜,我怎么能做到这一点呢 @app.route('/preprocess') def pre_process(): thr = threading.Thread(target=PreProcessor().initiate_preprocess_task()) thr.start() return "Pre-process task initiated!" if __name__

我只需要在调用路由后运行一个异步任务。任务启动后应返回响应。如果不在python中使用RabbitMQ和芹菜,我怎么能做到这一点呢

@app.route('/preprocess')
def pre_process():
    thr = threading.Thread(target=PreProcessor().initiate_preprocess_task())
thr.start()
return "Pre-process task initiated!"

if __name__ == '__main__':
    app.run(threaded=True, use_reloader=True)