Python 3.7+Linux · macOStimefunction
time.clock_settime_ns()
POSIX clocks
Sets the system clock clk_id to a value in nanoseconds (an int). Unix: Linux and macOS, administrator rights required.
Syntax
time.clock_settime_ns(clk_id, time)
Same limits as clock_settime(): only CLOCK_REALTIME, PermissionError without rights, OSError EINVAL for monotonic clocks. The value is an integer number of nanoseconds since the epoch; a float is a TypeError here.
Examples
import time
try:
time.clock_settime_ns(time.CLOCK_MONOTONIC, 0)
except OSError as e:
print(e.errno) # → 22
import time
try:
time.clock_settime_ns(time.CLOCK_REALTIME, 1.5)
except TypeError as e:
print(type(e).__name__) # → TypeError
See also
Common errors
Open in the full glossarydocs.python.orgReport an inaccuracy