[Bugfix][Core] Update cancellation logic in generate() to handle Generator exits (#19225)

Co-authored-by: Adolfo Victoria <adovi@meta.com>
This commit is contained in:
Adolfo Victoria
2025-06-06 20:17:54 +00:00
committed by GitHub
co-authored by Adolfo Victoria
parent aad30bd306
commit ca27f0f9c1
2 changed files with 129 additions and 45 deletions
+3 -2
View File
@@ -332,8 +332,9 @@ class AsyncLLM(EngineClient):
yield out
# If the request is disconnected by the client, generate()
# is cancelled. So, we abort the request if we end up here.
except asyncio.CancelledError:
# is cancelled or the generator is garbage collected. So,
# we abort the request if we end up here.
except (asyncio.CancelledError, GeneratorExit):
await self.abort(request_id)
if self.log_requests:
logger.info("Request %s aborted.", request_id)