fix: set change during iteration when dispatching listeners#1370
Merged
fix: set change during iteration when dispatching listeners#1370
Conversation
20 tasks
An existing listener may add new listeners to process ServiceInfo when it sees a record. We need to make a copy of the listeners set before iterating them to avoid `set changed size during iteration` Fixes ``` 2024-04-12 16:31:25.699 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() Traceback (most recent call last): File "/opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/selector_events.py", line 1248, in _read_ready self._protocol.datagram_received(data, addr) File "src/zeroconf/_listener.py", line 86, in zeroconf._listener.AsyncListener.datagram_received File "src/zeroconf/_listener.py", line 104, in zeroconf._listener.AsyncListener.datagram_received File "src/zeroconf/_listener.py", line 175, in zeroconf._listener.AsyncListener._process_datagram_at_time File "src/zeroconf/_handlers/record_manager.py", line 161, in zeroconf._handlers.record_manager.RecordManager.async_updates_from_response File "src/zeroconf/_handlers/record_manager.py", line 70, in zeroconf._handlers.record_manager.RecordManager.async_updates_complete RuntimeError: set changed size during iteration ```
cc9f207 to
d5de7a5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An existing listener may add new listeners to process
ServiceInfowhen it sees a record (or for other reasons). We need to make a copy of the listeners set before iterating them to avoidset changed size during iterationFixes