QueueCapacityChecker

class lsst.ts.salobj.topics.QueueCapacityChecker(descr: str, log: logging.Logger, queue_len: int)

Bases: object

Log warnings for a fixed-length queue that should contain no more than one item.

Call check_nitems to check the number of items in the queue. This will log a warning or error, if appropriate.

Parameters
descrstr

Brief description of queue, e.g. “python read queue” or “DDS read queue”.

loglogging.Logger

Logger to which to write messages.

queue_lenint

Length of queue

Notes

Once a message has been logged for a particular threshold, no more messages are sent until either the queue fills enough to cross the next warning threshold or empties enough to reduce the warning threshold.

Log messages are warnings unless the queue is full. A full queue produces an error because data is likely to have been lost.

Attributes
warn_thresholdsList [int]

Values for warn_threshold (see next item). Set to:

  • 5-10 elements, whichever is closest to queue_len/10

  • 1/2 full, but only if queue_len >= 20

  • 9/10 full

  • full

The corresponding reset thresholds are 1/2 these values.

warn_thresholdint or None

A call to check_nitems(n) with n > warn_threshold will produce a log message and update warn_threshold and reset__threshold as follows:

  • warn_threshold is set to the largest warn threshold <= n in warn_thresholds, or None if the queue is full.

  • reset_threshold is set to the half of the next lower warning threshold.

reset_thresholdint or None

A call to check_nitems(n) with n < reset_threshold will reduce warn_threshold and reset_threshold as follows:

  • reset_threshold is set to the largest reset threshold <= n, or None if the queue is empty.

  • warn_threshold is set to the warning threshold corresponding to one reset higher reset level.

Methods Summary

check_nitems(nitems)

Check the number of items in the queue and log a message if appropriate.

Methods Documentation

check_nitems(nitems: int) bool

Check the number of items in the queue and log a message if appropriate.

Parameters
nitemsint

Number of elements in the queue.

Returns
did_log: bool

True if a message was logged.