I am using AsyncWebSocketConsumer and I want to put consumer to sleep for 10 seconds while handling one specific event. So, on receiving that event I am calling await asyncio.sleep(10). But problem with this is that it is blocking events to this consumer instance for next 10 seconds.
My question is that if I am using AsyncConsumer, shouldn't it continue sending future events even though I am on async sleep?
I have been going through the code of daphne server and found out following:
def onMessage(self, payload, isBinary):
# If we're muted, do nothing.
if self.muted:
logger.debug("Muting incoming frame on %s", self.client_addr)
return
logger.debug("WebSocket incoming frame on %s", self.client_addr)
self.last_ping = time.time()
if isBinary:
self.application_queue.put_nowait(
{"type": "websocket.receive", "bytes": payload}
)
else:
self.application_queue.put_nowait(
{"type": "websocket.receive", "text": payload.decode("utf8")}
)
which means on receiving new event from frontend, it creates a new task and add it to async queue for consumer to consume. So, why sleep on one async task blocking other task? Am I missing something here?