Repository navigation
pyro: optional client lock so one client can't interrupt another's measurement - #445
Open
JayChien04717 wants to merge 4 commits into
Open
JayChien04717 wants to merge 4 commits into
JayChien04717 wants to merge 4 commits into
Conversation
Previously, if two clients shared one QickSoc server, a second client's start_readout() silently aborted the first client's readout, and the first client's poll_data() loop could then consume the second client's data. start_server() now (by default) wraps the QickSoc class and its autoproxied members so every public method goes through a per-connection lock. A client owns the QICK while it has a call in progress and for lock_hold_time seconds after its last call; other clients' calls block until it is idle or disconnects. Internal calls from server-side threads are not locked. Adds soc.get_lock_status() and client_lock/lock_hold_time options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Waiting clients can now see why they're waiting and for how long: - queued clients are served first-come-first-served - wait_for_lock(timeout) waits for at most `timeout` seconds while keeping the caller's place in the queue, and returns a status dict (granted, owner, queue position, owner progress), so clients can poll and stay cancellable - report_lock_progress(info) lets the owner publish its progress; the server-side readout progress of the current round is included as a fallback - get_lock_status() reports the same status without waiting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pyro4 drops and reopens a proxy's connection after a KeyboardInterrupt during a call, and autoproxied members (soc.streamer, soc.tproc) use their own connections. Keying the lock on the connection made a client's own cleanup calls after Ctrl-C (e.g. stop_tproc) queue behind itself for lock_hold_time, so they timed out. Ownership is now per peer IP; a client is released on disconnect only once all of its connections are closed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Motivation
In our lab, several users calibrate chips on one shared QICK board, each from their own PC. To support this multi-user chip calibration, the board must be shared safely: when one user starts a measurement, it must not break another user's calibration run that is already in progress, and a waiting user should be able to see that the board is busy.
Problem
When several PCs connect to the same
start_server()QickSoc, a second client'sacquire()silently aborts the first client's measurement:start_readout()stops the tProc and the streamer loop. The first client gets no error. Becausestop_flagis then cleared again, the first client'spoll_data()loop can go on to consume the second client's data packets, so both clients may end up with corrupted results.Change (
pyro.pyonly)start_server()gets two new options,client_lock=Trueandlock_hold_time=5.0. With the lock enabled:lock_hold_timeseconds after its last call. This covers the client-side gaps between rounds and between sweep points.get_lock_status(): owner, queue, the owner's progress.wait_for_lock(timeout): a bounded wait that keeps the caller's place in the queue and returns the same status dict. Clients can poll it to show who holds the board and how far along that client is, and can stay cancellable while waiting.report_lock_progress(info): the owner publishes its progress. The server-side readout progress of the current round is included as a fallback.Notes
KeyboardInterruptduring a call, and autoproxied objects use connections of their own. With per-connection identity, a client's own cleanup calls after Ctrl-C (e.g.stop_tproc) would queue behind itself. As a consequence, several notebooks on the same PC share ownership.client_lockdefaults toTruehere. If maintainers would prefer opt-in, I can change the default toFalse.wait_for_lock()have not been tested on hardware yet.🤖 Generated with Claude Code