Skip to content

Commit

Permalink
Copy subscriptions before iteration
Browse files Browse the repository at this point in the history
This ensures that if a callback modifies the dictionary there is no
'dictionary changed size during iteration' error.
  • Loading branch information
joeshannon committed May 17, 2023
1 parent aaccc3f commit d652ca9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/blueapi/core/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ def publish(self, event: E, correlation_id: Optional[str] = None) -> None:
event with other events
"""

for callback in self._subscriptions.values():
for callback in list(self._subscriptions.values()):
callback(event, correlation_id)

0 comments on commit d652ca9

Please sign in to comment.