<p>In Python 2.6, a new "timeout" parameter was added to the httplib.HTTPConnection class:
<a href="http://docs.python.org/library/httplib.html#httplib.HTTPConnection" rel="nofollow noreferrer">http://docs.python.org/library/httplib.html#httplib.HTTPConnection</a></p>

<p>However, this is only a timeout for the connection to a server.  I am looking to set a timeout value for the <b>request</b>, not the connection.  This doesn't seem to be supported by httplib.</p>

<p>Is there any way to emulate this behavior?</p>

You can set a global socket timeout
(*)
:
```
```
import socket

timeout = 10
socket.setdefaulttimeout(timeout)
```
```
(*)
EDIT
: As people in the comments correctly point out: This is technically true, but it only has predictable results for tasks that involve a single socket operation. An HTTP request consists of multiple socket operations (e.g. DNS requests or other things that might be abstracted away from an HTTP client). The timeout of the overall operation becomes unpredictable because of that.