pynetdicom.timer.Timer

class pynetdicom.timer.Timer(timeout: float | None)[source]

A generic timer.

Implementation of the DICOM Upper Layer’s ARTIM timer. The ARTIM timer is used by the state machine to monitor connection and response timeouts. This class may also be used as a general purpose expiry timer.

A timeout of None implies that expired always returns False and remaining always returns 1. A timeout of float implies that:

  • If not yet started, expired returns False and remaining returns timeout

  • If started then expired returns False until the time since starting is greater than timeout after which it returns True. remaining returns the number of seconds until expired returns True (will return negative value after expiry)

  • If started then stopped before the timeout then expired returns False, if stopped after the time since starting is greater than timeout then returns True. remaining always returns the number of seconds until expired returns True.

References

__init__(timeout: float | None) None[source]

Create a new Timer.

Parameters:

timeout (numeric or None) – The number of seconds before the timer expires. A value of None means the timer never expires.

Methods

__init__(timeout)

Create a new Timer.

restart()

Restart the timer.

start()

Resets and starts the timer running.

stop()

Stops the timer and resets it.

Attributes

expired

Check if the timer has expired.

remaining

Return the number of seconds remaining until timeout.

timeout

Return the number of seconds set for timeout.

property expired: bool

Check if the timer has expired.

Returns:

True if the timer has expired, False otherwise

Return type:

bool

property remaining: float

Return the number of seconds remaining until timeout.

Returns 1 if the timer is set to never expire.

restart() None[source]

Restart the timer.

start() None[source]

Resets and starts the timer running.

stop() None[source]

Stops the timer and resets it.

property timeout: float | None

Return the number of seconds set for timeout.