VirtualClient

For conceptual usage, see:

class pyrogue.interfaces.VirtualClient(addr='localhost', port=9099, linkTimeout=None, requestStallTimeout=None)[source]

A full featured client interface for Rogue. This can be used in scripts or other clients which require remote access to the running Rogue instance.

This class ues a custom factory ensuring that only one instance of this class is created in a python script for a given remote connection.

Parameters:
  • addr (str, default: 'localhost') – host address

  • port (int, default: 9099) – host port

  • linkTimeout (float | None, default: None) – Idle timeout in seconds before the client marks the link down when no publish updates or successful replies have been observed. This is the primary operational timeout knob for both hardware and simulation applications.

  • requestStallTimeout (float | None, default: None) – Optional policy timeout for how long a single in-flight request may remain outstanding before the client declares the connection stalled. This is disabled by default and is typically only useful when a deployment has a well-defined upper bound for legitimate request time.

Variables:
  • linked (bool) – link state

  • root (obj) – root class reference

Return type:

VirtualClient

addLinkMonitor(function)[source]

Add a link monitor callback function. This function will be called any time the link state changes. A single boolean argument will be passed to the callback function containing the current link state.

Parameters:

function (Callable[[bool], None]) – Callback function with the form function(linkState: bool).

Return type:

None

remLinkMonitor(function)[source]

Remove a previously added link monitor function.

Parameters:

function (Callable[[bool], None]) – Previously registered callback function.

Return type:

None

property linked: bool

Whether the client is currently linked to the server.

property linkTimeout: float

Idle timeout in seconds before the link is considered down.

property requestStallTimeout: float | None

Optional maximum in-flight request age before it is treated as stalled.

setTimeoutConfig(*, linkTimeout=None, requestStallTimeout=None)[source]

Update link and request-stall timeout settings.

linkTimeout is the normal tuning knob for clients that need to tolerate longer busy periods. requestStallTimeout is an optional policy threshold and is most useful only when a deployment has a clear, finite upper bound for legitimate request duration.

Return type:

None

Parameters:
  • linkTimeout (float | None)

  • requestStallTimeout (float | None)

stopMonitor()[source]

Stop the link-monitor thread without releasing ZMQ resources.

Use this when a long-lived client must drop link-heartbeat polling but the ZMQ transport must remain open. The intended caller is a host script that hands a VirtualClient to an interactive wrapper (for example pysmurf) and wants to silence the monitor on shutdown without losing the connection. stop() is the wrong choice for that case because it also closes the C++ ZmqClient sockets and removes the instance from ClientCache.

After stopMonitor() returns the client still services _remoteAttr calls and SUB publish updates; only the periodic link-state heartbeat is disabled. Idempotent; safe to call from any thread other than _monThread itself.

Return type:

None

stop()[source]

Stop the monitor thread and release the underlying ZMQ resources.

After stop() returns the C++ sockets and ZMQ context are released and this instance is removed from ClientCache; a subsequent VirtualClient(addr, port) therefore constructs a fresh, fully connected instance instead of returning the torn-down one.

Return type:

None

property root: VirtualNode

Return the connected virtual root node.