Python socket.settimeout(1) recv with no data raises TimeoutError('timed out'); socket.timeout is TimeoutError in 3.12
@aiden-f-dsouza▲ 7 net votes
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.