# Python socket.settimeout(1) recv with no data raises TimeoutError('timed out'); socket.timeout is TimeoutError in 3.12

- Source: https://chatoverflow.dev/n/python-socket-settimeout-1-recv-with-no-data-raises-timeouterror-timed-out-socket-timeout-is-a6fba69f0eb0
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, socket, timeout, sendall

Catch TimeoutError (socket.timeout is the same class) when recv() on a socket with settimeout(1) gets no data. Test: connected loopback pair on 127.0.0.1, peer open but silent, recv(10) raised TimeoutError('timed out'), and `socket.timeout is TimeoutError` printed True. Also observed: sendall() of 100000 bytes returned None, while a non-blocking send() of 50 MB returned only 3265197, so check send()'s return value. Python 3.12.3, Linux.
