Make tool position updates robust to None entries and subscriber errors - #24
Open
BrennanTM wants to merge 1 commit into
Open
Make tool position updates robust to None entries and subscriber errors#24BrennanTM wants to merge 1 commit into
BrennanTM wants to merge 1 commit into
Conversation
Four related robustness fixes: - ToolPositionsServer.recordNewPosition dereferenced a stored None position (the table's type and publish path both allow None values). - ToolPositionsClient's receive loop dereferenced None entries received from the wire when comparing against previous positions, killing the loop with AttributeError. Also reuse the already-deserialized positions dict instead of deserializing the message a second time. - An exception raised by any subscriber to sigLatestPositionsChanged propagated out of the receive loop into a task wrapper that swallows it, permanently freezing position updates while the GUI stayed responsive. Log the exception and keep the loop alive instead. - The same failure mode existed for sigIsConnectedChanged, emitted via _updateIsConnected from inside both the receive and monitor loops (e.g. CameraPanel's subscriber performs a synchronous ZMQ request and can raise); guard that emit the same way. Note: within a single update, Signal.emit still stops at the first raising subscriber, so later-priority subscribers miss that one event; changing per-subscriber isolation semantics in Signal.emit would be a global behavior change and is left out of scope here.
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.
What broke — in
Devices/:ToolPositionsServer.recordNewPositionand the client receive loop both dereferencedNoneposition entries (the publish format allows them;recordNewPosition(key, None)over RPC stores one) →AttributeErrorkilled the client loop.sigLatestPositionsChangedpropagated out of the receive loop intoasyncCreateTask's swallow-and-log wrapper → tracking froze permanently while the GUI stayed responsive.sigIsConnectedChanged, emitted via_updateIsConnected()from both the receive and monitor loops (CameraPanel's subscriber does a sync ZMQ request and can raise).Fix — null-guard both comparison paths; catch, log, and continue around both emits (
except Exception, soCancelledErrorstill cancels the loop). Also stop deserializing each message twice.Note —
Signal.emitstill stops at the first raising subscriber within one update, so later subscribers miss that single event; changing that would be a globalSignalbehavior change, so it's out of scope here — happy to follow up if you'd prefer it.Tests —
tests/test_Devices/test_toolPositionsRobustness.py(4): a real server/client pair over ZMQ on random localhost ports, server in its own thread. Verified on macOS / Py 3.13; not yet run on Windows.