Non-blocking read() in httplib?

Jarek Zgoda jzgoda at gazeta.usun.pl
Mon Jul 12 15:15:24 EDT 2004


Marcin Ciura <ciuraNOSPAM at zeus.polsl.gliwice.pl> pisze:

> Sometimes the read() call blocks forever for no obvious reason 
> (response.status is OK); it even cannot be interrupted from the keyboard 
> (on Windows).
> 
> I would like to defend against this by throwing an exception when the 
> read() lasts too long. But I cannot use select.select(), because 
> HTTPResponse has no fileno() method. Neither can I use signal.alarm(), 
> as it is for Unixes only.
> 
> Is there any other way to break read() or make it non-blocking?

You can try to write your own HTTP client module, that uses
asyncore/asynchat. You may find a minimal implementation in my project's
CVS (URL in signature). It is based on code found in "EffNews Part 1:
Fetching RSS Files" tutorial (http://www.effbot.org/zone/effnews-1.htm).

-- 
Jarek Zgoda
http://jpa.berlios.de/



More information about the Python-list mailing list