abs_timeout¶
Absolute timeout helper for managing deadlines.
This module provides a simple timeout class that tracks an absolute expiration time and returns the remaining time on demand - so that a fixed deadline is not shifted forward by the time spent between its creation and its uses.
Example
tmo = abs_timeout.AbsTimeout(30)
time_left = tmo.get() # seconds remaining, shrinking over time
if time_left == 0:
deadline_expired() # handle the expired 30s deadline
AbsTimeout
¶
Timeout tracker with absolute expiration time.
Computes expiration time on creation and returns remaining time when get() is called. Useful for passing to functions that accept timeout parameters.
Source code in py_misc_utils/abs_timeout.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
get()
¶
Get remaining time until expiration.
Returns:
| Type | Description |
|---|---|
|
Remaining time in seconds (>= 0), or None if no timeout was set. |
Source code in py_misc_utils/abs_timeout.py
38 39 40 41 42 43 44 | |