timeutils – Time Utilites

class eventmq.utils.timeutils.IntervalIter(start_value, interval_secs)

represents an interval (in seconds) and it’s next() execution time

Usage:

# interval of 5min using monotonic clock (assume it starts at 0 for the # sake of the example) interval = IntervalIter(monotonic, 300) # Py2

interval.next() # 300 interval.next() # 600

# Py3 next(interval) # 300 next(interval) # 600

__init__(start_value, interval_secs)
Parameters:
  • start_value (numeric) – the timestamp to begin with. usually gotten via monotonic() or timestamp()
  • interval_secs (int) – the number of seconds between intervals
__weakref__

list of weak references to the object (if defined)

eventmq.utils.timeutils.monotonic()

Returns (float) seconds since boot, or something close to it. This value will never count down so it’s useful for cases where DST would mess up time.time() arithmetic (e.g. heartbeats).

eventmq.utils.timeutils.seconds_until(ts)

Calculates the number of seconds until ts by subtracting it from time.time()

eventmq.utils.timeutils.timestamp()