Flask long routines

后端 未结 2 1320
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 05:56

I have to do some long work in my Flask app. And I want to do it async. Just start working, and then check status from javascript.

I\'m trying to do something like:

2条回答
  •  一生所求
    2020-12-16 06:19

    I would use a message broker such as rabbitmq or activemq. The flask process would add jobs to the message queue and a long running worker process (or pool or worker processes) would take jobs off the queue to complete them. The worker process could update a database to allow the flask server to know the current status of the job and pass this information to the clients.

    Using celery seems to be a nice way to do this.

提交回复
热议问题