Skip to content

Commit

Permalink
Fix RuntimeError: dictionary changed size during iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Jan 10, 2025
1 parent 1493c89 commit bded639
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/lobby.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, app_state: PychessGlobalAppState):
# below methods maybe best in separate class eventually
async def lobby_broadcast(self, response):
# log.debug("lobby_broadcast: %r to %r", response, self.lobbysockets)
for username, ws_set in self.lobbysockets.items():
for username, ws_set in list(self.lobbysockets.items()):
for ws in list(ws_set):
await ws_send_json(ws, response)

Expand All @@ -44,7 +44,7 @@ async def lobby_broadcast_seeks(self):
for seek in self.app_state.seeks.values():
await self.app_state.users.get(seek.creator.username)

for username, ws_set in self.lobbysockets.items():
for username, ws_set in list(self.lobbysockets.items()):
ws_user = await self.app_state.users.get(username)
compatible_seeks = get_seeks(ws_user, self.app_state.seeks.values())
for ws in list(ws_set):
Expand Down

0 comments on commit bded639

Please sign in to comment.