[issue1348] httplib closes socket, then tries to read from it

vila report at bugs.python.org
Tue Nov 27 15:21:58 CET 2007


vila added the comment:

Well I was confused.

In fact, I have a working http/1.1 client which indeed works around that
close.

HTTPConnection.close() must be called once the response has been
processed or the next request can't be handled since        
HTTPConnection.__state is not  _CS_IDLE.

That may be a different problem than the one Bill is after though.

I work around it by saving the sock attribute before the call in a class
inherited from HTTPConnection:

         # Preserve our preciousss
        sock = self.sock
        self.sock = None
        # Let httplib.HTTPConnection do its housekeeping 
        self.close()
        # Restore our preciousss
        self.sock = sock

So not doing the close() is harmless but doing self.sock = None in 
HTTPConnection.close() still break hopes of persistent connections.

May be that method should be splitted...

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1348>
__________________________________


More information about the Python-bugs-list mailing list