Python Glossary Русский

all Python 3Linux · macOSsignalfunction

signal.getitimer()

timers

Returns the state of an interval timer: a pair (time left, period) in seconds. Unix only (Linux, macOS).

Syntax

delay, interval = signal.getitimer(which)

A result of (0.0, 0.0) means 'not armed': a way to check whether a library left an active timer behind. A timer armed with alarm is visible to getitimer(ITIMER_REAL) as well — it is the same timer. The remaining time is a snapshot: it has already shrunk by the time you print it.

Examples

import signal
print(signal.getitimer(signal.ITIMER_REAL))  # → (0.0, 0.0)
signal.alarm(10)
delay, interval = signal.getitimer(signal.ITIMER_REAL)
print(0 < delay <= 10, interval)  # → True 0.0 — alarm виден как ITIMER_REAL
signal.alarm(0)

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy