Django request/response 多线程

Django request/response multithreading

我的应用程序的工作流程是 -

User submits a file
On receiving -> process_file()
return response

如果 process_file() 花费很多时间,这可能会导致超时,所以我怎么能发回 response 之前然后处理文件并稍后将所需的输出发送给用户。
我已经查看了 django-celery,但我认为它对于我正在尝试构建的小型应用程序来说相当沉重。

更新:我在网上搜索了一下,如果有人想用芹菜,这里有一个不错的博客post,可以帮助你解决这种情况 - [Link]

您可以使用 Celery 来解决这个问题:

Celery is an asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well.

The execution units, called tasks, are executed concurrently on a single or more worker servers using multiprocessing, Eventlet, or gevent. Tasks can execute asynchronously (in the background) or synchronously (wait until ready).