Poller
This module provides a general framework and mechanism for polling.
- class ska_tango_base.poller.poller.Poller[source]
A generic hardware polling mechanism.
- __init__(poll_model: PollModel[PollRequestT, PollResponseT], poll_rate: float = 1.0, logger: Logger | None = None) None[source]
Initialise a new instance.
- Parameters:
poll_model – an object that this poller will call to both execute polls and provide with results
poll_rate – how long (in seconds) to wait after polling, before polling again
logger – a logger for this poller to use for logging
- class ska_tango_base.poller.poller.PollModel[source]
Abstract base class for a polling model.
- get_request() PollRequestT[source]
Return the polling request to be executed at the next poll.
This is a hook called by the poller each polling loop, to obtain instructions on what it should do on the next poll.
- Returns:
attribute request to be executed at the next poll.
- Raises:
NotImplementedError – because this class is abstract
- poll(poll_request: PollRequestT) PollResponseT[source]
Perform a single poll.
This is a hook called by the poller each polling loop.
- Parameters:
poll_request – specification of what is to be done on the poll. It might, for example, contain a list of reads and writes to be executed.
- Returns:
responses from this poll
- Raises:
NotImplementedError – because this class is abstract.
- polling_started() None[source]
Respond to polling having started.
This is a hook called by the poller when it starts polling, and should not raise any exceptions.
- polling_stopped() None[source]
Respond to polling having stopped.
This is a hook called by the poller when it stops polling, and should not raise any exceptions.
- poll_succeeded(poll_response: PollResponseT) None[source]
Handle successful completion of a poll.
This is a hook called by the poller upon the successful completion of a poll.
- Parameters:
poll_response – The response to the poll, containing for example any values read.
- poll_failed(exception: Exception) None[source]
Respond to an exception being raised by a poll attempt.
This is a hook called by the poller when an exception occurs. The polling loop itself never raises exceptions. It catches everything and simply calls this hook to let the polling model know what it caught. This hook may not raise an exception itself.
- Parameters:
exception – the exception that was raised by a recent poll attempt.
- class ska_tango_base.poller.poller.PollRequestT
Type variable for object specifying what the poller should do next poll.
alias of TypeVar(‘PollRequestT’)
- class ska_tango_base.poller.poller.PollResponseT
Type variable for object containing the result of the previous poll.
alias of TypeVar(‘PollResponseT’)