【发布时间】:2020-11-25 21:03:51
【问题描述】:
在 Django 视图返回响应后,我正在尝试执行一个长时间运行的函数(例如:sleep(30))。我已经尝试实施针对类似问题提出的解决方案:
- How to execute code in Django after response has been sent
- Execute code in Django after response has been sent to the client
但是,当使用像 gunicorn 这样的 WSGI 服务器时,客户端的页面加载只有在长时间运行的函数完成运行后才能完成。
既然 Django supports asynchronous views 可以异步运行长时间运行的查询吗?
【问题讨论】:
标签: django python-asyncio