Replies: 1 comment 2 replies
-
Can you see if fastapi/fastapi#11360 can work for you? |
Beta Was this translation helpful? Give feedback.
2 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 submitted this same discussion to starlette encode/starlette#2215, but I thought that this might be a better form:
I see that starlette offers an async
is_disconnected
method on theirRequest
:https://github.com/encode/starlette/blob/844220819f1cfcf2726d1628dd4ea597182d6f3e/starlette/requests.py#L293
Here we see that
is_disconnected
callsself._receive()
(which is the asgireceive
function). I believe that this could possibly consume and discard a http.request message containing the request body.Is there any way to listen for disconnection (ideally create an Event that signals disconnection) without discarding any messages from
receive
? 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 asgi, so I may be missing something (or not asking in the right place), but I wanted to reach out to see if anyone here could point me in the right direction
Beta Was this translation helpful? Give feedback.
All reactions