set timeout to http response read method in python

Posted by nirtayeb on Stack Overflow See other posts from Stack Overflow or by nirtayeb
Published on 2010-04-03T23:32:03Z Indexed on 2010/04/03 23:43 UTC
Read the original article Hit count: 280

Filed under:
|
|

Hi,

I'm building a download manager in python for fun, and sometimes the connection to the server is still on but the server doesn't send me data, so read method (of HTTPResponse) block me forever. This happens, for example, when I download from a server, which located outside of my country, that limit the bandwidth to other countries.

How can I set a timeout for the read method (2 minutes for example)?

Thanks, Nir.

© Stack Overflow or respective owner

Related posts about python

Related posts about httpresponse