Skip to content

Commit

Permalink
Fix issue with send_queue in WSGIResponder
Browse files Browse the repository at this point in the history
  • Loading branch information
abersheeran committed Mar 13, 2024
1 parent 34e6f6c commit a593be6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion a2wsgi/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ async def __call__(self, scope: HTTPScope, receive: Receive, send: Send) -> None
await self.loop.run_in_executor(
self.executor, func, environ, self.start_response
)
await self.send_queue.join()
await self.send_queue.put(None)
# Sender may raise an exception, so we need to await it
# dont await send_queue.join() because it will never finish
await sender
if self.exc_info is not None:
raise self.exc_info[0].with_traceback(
self.exc_info[1], self.exc_info[2]
Expand All @@ -218,6 +221,8 @@ def send(self, message: typing.Optional[SendEvent]) -> None:
async def sender(self, send: Send) -> None:
while True:
message = await self.send_queue.get()
if message is None:
break
await send(message)
self.send_queue.task_done()

Expand Down

0 comments on commit a593be6

Please sign in to comment.