Skip to content
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

fix: handling client disconnect gracefully by propagating cancellation exception up to the chat completion handler #185

Open
wants to merge 18 commits into
base: development
Choose a base branch
from

Conversation

adubovik
Copy link
Collaborator

No description provided.

@adubovik adubovik self-assigned this Nov 13, 2024


@pytest.mark.parametrize("with_heartbeat", [True, False])
async def test_cancellation(with_heartbeat: bool):
Copy link
Contributor

@roman-romanov-o roman-romanov-o Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, extend this with the test:
1.Run chat completion
2.Inside of chat completion create nested tasks, that run forever
3.Cancel chat completion
4.Check that nested tasks are also canceled

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, added more tests

async def __aenter__(self):
return self

async def __aexit__(self, et, exc, tb):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the same naming, that official PEP introduces:

    async def __aexit__(self, exc_type, exc, tb):
        ...

It's quite easy to confuse et with something else, then exception type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@adubovik adubovik force-pushed the fix/propagate-cancellation-error branch from c764571 to 4a62262 Compare November 19, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants