Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ASGIMiddleware Receive #59

Merged
merged 3 commits into from
Jun 26, 2024
Merged

Fix ASGIMiddleware Receive #59

merged 3 commits into from
Jun 26, 2024

Conversation

abersheeran
Copy link
Owner

@abersheeran abersheeran commented Jun 26, 2024

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

@abersheeran abersheeran linked an issue Jun 26, 2024 that may be closed by this pull request
@abersheeran abersheeran changed the title Refactoring ASGIMiddleware design Fix ASGIMiddleware Receive Jun 26, 2024
@abersheeran abersheeran marked this pull request as ready for review June 26, 2024 09:35
@abersheeran abersheeran merged commit dd66cda into master Jun 26, 2024
32 checks passed
@abersheeran abersheeran deleted the fix-asgi branch June 26, 2024 09:39
@lmignon
Copy link

lmignon commented Jun 26, 2024

Thank you @abersheeran for the fix and improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Starlette StreamingResponse does not work anymore a2wsgi can't work with BaseHTTPMiddleware in Starlette
2 participants