all Python 3Exceptionsexception
signal.ItimerError
module exceptions
An error from setitimer or getitimer (a subclass of OSError).
Syntax
raise signal.ItimerError
It surfaces only around signal.setitimer() and getitimer() — a negative interval or an unknown timer type, say. Both functions are Unix-only; on Windows the attribute is missing entirely, so you get AttributeError instead of this error. Since it subclasses OSError, a broader except OSError catches it as well.
Examples
import signal
# signal.ItimerError есть только на Unix: setitimer/getitimer в Windows нет
# вовсе, поэтому пример проверяет наличие, а не полагается на него.
ItimerError = getattr(signal, 'ItimerError', None)
print(ItimerError is not None) # → ?
if ItimerError is not None:
try:
raise ItimerError
except ItimerError as e:
print(type(e).__name__) # → ?
See also
Open in the full glossarydocs.python.orgReport an inaccuracy