Python 3.13+Linuxosfunction
os.timerfd_gettime
os — events and timers (fd)
Return a timerfd's remaining time and interval (in seconds). Availability: Linux.
Syntax
os.timerfd_gettime(...)
It returns a pair: time left until the next expiration and the period, in seconds. For a disarmed timer both values are zero. The timer itself is not changed and the expiration count is not reset.
Examples
import os, time
fd = os.timerfd_create(time.CLOCK_MONOTONIC) # → ? только Linux: дескриптор таймера
print(os.timerfd_gettime(fd)) # → (0.0, 0.0) — таймер создан, но ещё не заведён
os.timerfd_settime(fd, initial=10.0, interval=2.0) # → ? только Linux: старт через 10 с, дальше каждые 2 с
print(os.timerfd_gettime(fd)) # → ? только Linux: примерно (9.99, 2.0) — остаток до срабатывания и период
os.close(fd) # → ? только Linux: после закрытия os.timerfd_gettime(fd) даст OSError [Errno 9] Bad file descriptor
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy