QueueCapacityChecker#

class lsst.ts.salobj.topics.QueueCapacityChecker(descr, log, queue_len)#

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:
  • descr (str) – Brief description of queue, e.g. “python read queue” or “DDS read queue”.

  • log (logging.Logger) – Logger to which to write messages.

  • queue_len (int) – Length of queue

warn_thresholds#

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.

Type:

List [int]

warn_threshold#

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.

Type:

int or None

reset_threshold#

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.

Type:

int or None

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.

Methods Summary

check_nitems(nitems)

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

Methods Documentation

check_nitems(nitems)#

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

Parameters:

nitems (int) – Number of elements in the queue.

Returns:

did_log – True if a message was logged.

Return type:

bool