-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Abort when coroutine is cancelled #1020
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
Conversation
@@ -385,8 +385,8 @@ async def generate( | |||
|
|||
async for request_output in stream: | |||
yield request_output | |||
except Exception as e: | |||
# If there is an exception, abort the request. | |||
except (Exception, asyncio.CancelledError) as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? I believe Exception
should already capture all exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in version 3.8: CancelledError is now a subclass of BaseException rather than Exception.
Apparently not, guess I tripped on that too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the fix!
…vllm-project#1020) Twin PR: [135](HabanaAI/vllm-hpu-extension#135) APC will use our implementation of attn --------- Co-authored-by: Michał Kuligowski <[email protected]>
There is a scene, while running
async for result in AsyncLLMEngine.generate(...)
,if caller cancel the coroutine at high level (ex. Sanic Framework cancel the coroutine which handling request when transport connection is disconnected), whether to need catchingasyncio.CancelledError
and aborting token generating in background?