Request.is_disconnected
could consume request body
#2215
Unanswered
msdrigg
asked this question in
Potential Issue
Replies: 3 comments
-
Linking fastapi/fastapi#8805 for context |
Beta Was this translation helpful? Give feedback.
0 replies
-
We are also searching for a way to implement this |
Beta Was this translation helpful? Give feedback.
0 replies
-
Can you try and see if fastapi/fastapi#11360 fix your problem? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For some background, I got here looking for a way to cancel costly actions if the client disconnects. I checked the source of Request.is_disconnected:
Here we see that
is_disconnected
callsself._receive()
(which consumes a asgi message). I believe that this could possibly consume and discard ahttp.request
message containing the request body.If this is actually a possible side effect, I believe that it should be avoided (or at least documented somewhere).
If this is not possible to fix, is there any way to listen for disconnection (ideally create an
Event
that signals disconnection) without consuming the request? I read the spec, but unless I buffer arbitrarily many messages fromreceive
, I don't know how I would do this.I am relatively new to async python web frameworks, so I may be missing something obvious (or asking in the right place), but I wanted to reach out to see if anyone here could help me
Beta Was this translation helpful? Give feedback.
All reactions