Use [`socket.settimeout()`][1] before you perform a blocking operation to control its timeout. So in your case it sounds like you don't want a timeout for `connect()`, but one for `recv()`. [1]: https://docs.python.org/2/library/socket.html#socket.socket.settimeout