-
Notifications
You must be signed in to change notification settings - Fork 126
avoid KeyError when track is already unpublished #743
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -821,11 +821,22 @@ def _on_room_event(self, event: proto_room.RoomEvent) -> None: | |
| rparticipant._track_publications[rpublication.sid] = rpublication | ||
| self.emit("track_published", rpublication, rparticipant) | ||
| elif which == "track_unpublished": | ||
| rparticipant = self._remote_participants[event.track_unpublished.participant_identity] | ||
| rpublication = rparticipant._track_publications.pop( | ||
| event.track_unpublished.publication_sid | ||
| ) | ||
| self.emit("track_unpublished", rpublication, rparticipant) | ||
| # The participant or publication may already have been removed by a | ||
| # racing disconnect or a duplicate event, so both lookups are done | ||
| # defensively and the emit is skipped when the entry is gone, | ||
| # mirroring the local_track_unpublished handler, instead of raising a | ||
| # KeyError that _listen_task logs as an error. | ||
| identity = event.track_unpublished.participant_identity | ||
| sid = event.track_unpublished.publication_sid | ||
| rparticipant = self._remote_participants.get(identity) | ||
| if rparticipant is not None: | ||
| rpublication = rparticipant._track_publications.pop(sid, None) | ||
| if rpublication is not None: | ||
| self.emit("track_unpublished", rpublication, rparticipant) | ||
| else: | ||
| logging.debug("track_unpublished for untracked publication sid %s", sid) | ||
| else: | ||
| logging.debug("track_unpublished for untracked participant %s", identity) | ||
| elif which == "track_subscribed": | ||
| owned_track_info = event.track_subscribed.track | ||
| track_info = owned_track_info.info | ||
|
Comment on lines
841
to
843
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 Other remote-track event handlers still use hard dictionary lookups and may crash under the same race conditions This PR defensively handles the case where (Refers to lines 840-865) Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.