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

Incompatibility with anyio v3 #2517

Closed
jonathanslenders opened this issue Feb 16, 2024 · 0 comments
Closed

Incompatibility with anyio v3 #2517

jonathanslenders opened this issue Feb 16, 2024 · 0 comments

Comments

@jonathanslenders
Copy link

jonathanslenders commented Feb 16, 2024

The following issue happens when trying to reproduce the snippet from #2516 on anyio v3:

    | Traceback (most recent call last):
    |   File "/home/jonathan/git/starlette/starlette/middleware/base.py", line 137, in close_recv_stream_on_response_sent
    |     recv_stream.close()
    | AttributeError: 'MemoryObjectReceiveStream' object has no attribute 'close'

The fix is simple:

--- a/starlette/middleware/base.py
+++ b/starlette/middleware/base.py
@@ -134,7 +134,7 @@ class BaseHTTPMiddleware:

             async def close_recv_stream_on_response_sent() -> None:
                 await response_sent.wait()
-                recv_stream.close()
+                await recv_stream.aclose()

             async def send_no_error(message: Message) -> None:
                 try:

Important

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants