InterruptedError
PythonERRORNotableOS ErrorHIGH confidence

System call interrupted by signal

Production Risk

Very rare in Python 3.5+; if seen, check signal handling code.

What this means

A subclass of OSError (errno EINTR) raised when a system call is interrupted by a signal. In Python 3.5+, most I/O calls automatically retry on EINTR; InterruptedError is now rare in user code.

Why it happens
  1. 1A signal arrives during a slow system call (pre-Python 3.5)
  2. 2A signal handler raises an exception that propagates through a syscall
How to reproduce

Low-level socket call interrupted by a signal (pre-3.5 behaviour).

trigger — this will error
trigger — this will error
# Python 3.5+ automatically retries EINTR for most I/O
# Rare to see in modern Python; more common in C extensions

expected output

InterruptedError: [Errno 4] Interrupted function call

Fix

Use Python 3.5+ (automatic EINTR retry)

WHEN If still seeing InterruptedError in modern code

Use Python 3.5+ (automatic EINTR retry)
# Python 3.5+ (PEP 475) retries most syscalls on EINTR automatically
# If you do see it, upgrade Python or use signal.siginterrupt(sig, False)
import signal
signal.siginterrupt(signal.SIGUSR1, False)

Why this works

PEP 475 made Python 3.5+ automatically restart interrupted syscalls, eliminating most InterruptedError cases.

Code examples
Triggerpython
# Pre-Python 3.5: system call interrupted by signal
# import socket; s.recv(4096)  # EINTR raised InterruptedError
Handle with retrypython
try:
    data = sock.recv(4096)
except InterruptedError:
    data = sock.recv(4096)  # retry
Avoid in Python 3.5+ (auto-retry)python
# Python 3.5+ (PEP 475) retries EINTR automatically
import signal
signal.siginterrupt(signal.SIGUSR1, False)
Same error in other languages
Version notes

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Python errors