Python 3.3+Exceptionsexception
BlockingIOError
built-in exceptions
A non-blocking I/O operation would have blocked (a subclass of OSError).
Syntax
raise BlockingIOError
It never appears on its own: you only see it after putting a socket or file into non-blocking mode (socket.setblocking(False), the O_NONBLOCK flag), when no data has arrived yet or the send buffer is full — the underlying errno is EAGAIN/EWOULDBLOCK. Treat it as "try again later", not as breakage: wait for readiness with selectors or asyncio instead of spinning in a tight retry loop. After a partial write, characters_written tells you how many bytes did get through.
Examples
try:
raise BlockingIOError
except BlockingIOError as e:
print(type(e).__name__) # → BlockingIOError
See also
Open in the full glossarydocs.python.orgReport an inaccuracy