abersheeran / a2wsgi

Convert WSGI app to ASGI app or ASGI app to WSGI app.
Apache License 2.0
226 stars 20 forks source link

Fix ASGIMiddleware Receive #59

Closed abersheeran closed 4 months ago

abersheeran commented 4 months ago

fixes #58 #45

In Starlette, there are many codes that use receive to determine whether the connection is disconnected and continue to send. The current ASGIMiddleware is designed to save resources and handles two requests in the same thread, which will cause send to be blocked by receive.

https://github.com/encode/starlette/blob/5a1bec33f8d6a669a3670f51034de83292d19408/starlette/responses.py#L257-L265

lmignon commented 4 months ago

Thank you @abersheeran for the fix and improvement!