Skip to content

Commit

Permalink
Fix iteration over message handlers (#797)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Jan 22, 2024
1 parent 8b16e86 commit a773de8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pychromecast/socket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def new_cast_status(self, cast_status):
for namespace in self.app_namespaces:
if namespace in self._handlers:
self._ensure_channel_connected(self.destination_id)
for handler in self._handlers[namespace]:
for handler in set(self._handlers[namespace]):
handler.channel_connected()

def _gen_request_id(self):
Expand Down Expand Up @@ -730,7 +730,7 @@ def _route_message(self, message, data: dict):
)

# message handlers
for handler in self._handlers[message.namespace]:
for handler in set(self._handlers[message.namespace]):
try:
handled = handler.receive_message(message, data)

Expand Down Expand Up @@ -773,8 +773,8 @@ def _cleanup(self):
except Exception: # pylint: disable=broad-except
pass

for namespace in self._handlers.values():
for handler in namespace:
for handlers in self._handlers.values():
for handler in set(handlers):
try:
handler.tear_down()
except Exception: # pylint: disable=broad-except
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def handle_channel_disconnected(self):
"""Handles a channel being disconnected."""
for namespace in self.app_namespaces:
if namespace in self._handlers:
for handler in self._handlers[namespace]:
for handler in set(self._handlers[namespace]):
handler.channel_disconnected()

self.app_namespaces = []
Expand Down

0 comments on commit a773de8

Please sign in to comment.