【发布时间】:2020-02-12 13:01:07
【问题描述】:
我在本地运行开发服务器
python manage.py runserver 8000
然后我运行一个使用下面消费者的脚本
from channels.generic.websocket import AsyncJsonWebsocketConsumer
class MyConsumer(AsyncJsonWebsocketConsumer):
async def connect(self):
import time
time.sleep(99999999)
await self.accept()
一切运行良好,消费者按预期睡了很长时间。但是我无法从浏览器访问http://127.0.0.1:8000/。
这个问题在现实生活中更大,因为消费者需要向同一台服务器发出 HTTP 请求 - 并且最终陷入死锁。
这是预期的行为吗?如何在慢速消费者运行时允许调用我的服务器?
【问题讨论】:
标签: asynchronous deadlock django-channels