TransportBase#
- class TransportBase[source]#
Bases:
ABCThe contract a transport implements:
_open_session,_teardown_session,is_open, plus shared ownership.Ownership is deferred-teardown: opened by the first owner, torn down by the last. Holders are the objects that own the connection, so a device serving several categories holds the transport once on its own behalf and does its own device-level teardown before releasing.
Initialize holder tracking and the reentrant lock.
Attributes
Whether the underlying connection is currently open.
Methods
Close and teardown; with a holder, remove it and tear down only when the last owner leaves.
Return the reentrant resource lock for atomic multi-step sequences; the holder may write/query/read inside it.
Open the connection (idempotent); with a holder, admit it and return True only for the first owner.
- open(holder: object | None = None) bool[source]#
Open the connection (idempotent); with a holder, admit it and return True only for the first owner.
- close(holder: object | None = None) None[source]#
Close and teardown; with a holder, remove it and tear down only when the last owner leaves.
A holder that needs to talk to the instrument before the connection goes (releasing a remote lock, say) does that in its own
closebefore calling this, while the session is still up.Raises
UnknownHolderErrorwhen an unrecognized holder closes while others still own the connection, because that is the case where ignoring it silently strands the real owners and leaves the connection open forever. Once the last owner has left there is nothing to strand, so a repeat close is a no-op and close stays idempotent.