TaurusFirstRead

Inheritance diagram of TaurusFirstRead
class TaurusFirstRead(*p, **k)[source]

First read manages a list of attributes that have to be read in the same period.

The helper runs a lightweight background thread that consumes an internal queue and performs a one-shot poll for every attribute requested. The thread auto-stops after a period of inactivity and is transparently restarted on demand whenever a new attribute is enqueued.

Import from taurus.core.taurusfirstread as:

from taurus.core.taurusfirstread import TaurusFirstRead
addAttribute(attr: TaurusAttribute)[source]

Adds an attribute to the queue for asynchronous reading.

The attribute will be processed by the internal background thread that batches reads occurring within the same polling period. This allows grouping and optimizing communication with devices.

Parameters:

attr (TaurusAttribute) – Object to be read.

execute(force_restart: bool = False)[source]

Start the worker thread if needed, optionally forcing a restart.

The worker is restarted on demand when force_restart is True, clearing the stop flag. If a live worker already exists and force_restart is False, this is a no-op.

init()[source]

Initializes the internal state and starts the background reading thread.

This method is intended to be called only once, during the first creation of the singleton instance. It sets up the task queue, control flags, and launches a daemon thread that continuously processes attribute read requests.

It uses an internal _initialized flag to prevent repeated initialization in case the method is accidentally invoked more than once.

stop(wait: bool = False, timeout: float | None = None)[source]

Request thread shutdown and optionally wait until it finishes.

Parameters:
  • wait – If True, drain pending work and block until the thread finishes.

  • timeout – Max seconds to wait when wait is True.

wait_until_idle()[source]

Block until all queued attributes have been processed.