Non-blocking read() in httplib?

Paul Rubin http
Mon Jul 12 15:43:09 EDT 2004


Marcin Ciura <ciuraNOSPAM at zeus.polsl.gliwice.pl> writes:
> 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?

I think I'd reach down into the response object and get the fileno.
>From httplib.py: 

    class HTTPResponse:
        # ...
        def __init__(self, sock, debuglevel=0, strict=0):
            self.fp = sock.makefile('rb', 0)
            self.debuglevel = debuglevel
            self.strict = strict

so maybe you can get the fileno from response.fp.



More information about the Python-list mailing list