Streaming request not being canceled when client disconnects #2866
-
Since upgrading to fastapi >= 0.115.7, which bumped my Startlette version from 0.38.5 to 0.45.3, no exception (not even the ClientDisconnect) is being raised when I cancel an http 2 streaming request, which is returning a StreamingResponse. I have a long running task that is an async generator. Inside of that generator, I was previously catching the async def long_running_async_generator():
try:
for i in range(10):
yield i
await asyncio.sleep(5)
except CancelledError as e:
print("cleaning up")
raise (e)
except Exception as e:
print("Other exception found:", e)
raise(e) Note that even the other open except clause (catching all other exceptions) is not being triggered either. The for loop would just continue to run. This is almost certainly related to https://github.com/encode/starlette/pull/2732/files. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Uvicorn version? |
Beta Was this translation helpful? Give feedback.
Bump it to the latest. It should solve the issue.