PlasmaCalcs.tools.timing.TimeLimit
- class PlasmaCalcs.tools.timing.TimeLimit(seconds)
Bases:
objectcontext manager which imposes a time limit, exiting with TimeoutError if internal code takes too long.Usage example:with TimeLimit(10):# any code in this block must complete within 10 seconds, else will crash with TimeoutError.- seconds: None or int
- timeout after this many seconds (unless code completes before then).Must be an integer, due to limitations of signal.alarm method.None, or <=0 –> no time limit
- __init__(seconds)
Methods
__init__(seconds)signal_handler(_signum, _frame)- static now()
- time() -> floating point numberReturn the current time in seconds since the Epoch.Fractions of a second may be present if the system clock provides them.
- signal_handler(_signum, _frame)
- raise TimeoutError.
- time_elapsed()
- returns time elapsed since entering the context.