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

Remove useless isinstance in server BaseEventsComponent #9260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions server/parsec/components/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,19 @@ async def sse_api_events_listen(
outcome = await self._register_client(
client_ctx=client_ctx, last_event_id=last_event_id, cancel_scope=cancel_scope
)
match outcome:
case (initial_organization_config_event, channel_receiver, registered_client):
pass
case SseAPiEventsListenBadOutcome() as error:
yield error
return

try:
match outcome:
case (initial_organization_config_event, channel_receiver, registered_client):
# Make sure to close the sender when leaving this scope
# This way, the receiver gets notified with an `anyio.EndOfStream`
with registered_client.channel_sender:
yield (initial_organization_config_event, channel_receiver)
case SseAPiEventsListenBadOutcome() as error:
yield error
# Make sure to close the sender when leaving this scope
# This way, the receiver gets notified with an `anyio.EndOfStream`
with registered_client.channel_sender:
yield (initial_organization_config_event, channel_receiver)
finally:
if not isinstance(outcome, SseAPiEventsListenBadOutcome):
# It's vital to unregister the client here given the memory location of the
# client (and hence the id resulting of it) will most likely be re-used !
self._registered_clients.pop(id(client_ctx))
# It's vital to unregister the client here given the memory location of the
# client (and hence the id resulting of it) will most likely be re-used !
self._registered_clients.pop(id(client_ctx))
Loading