Resetting state of http.client/httplib HTTPSConnection objects

C

Chris Down

This is a crosspost from python-tutor upon suggestion.

I am experiencing intermittent issues where an exception will be raised when
calling getresponse(), which makes the entire connection stuck in Request-sent
state. Is it possible to reset to idle state somehow without reinstantiating
the HTTPSConnection? I ideally want to keep the connection to the server, and
just reset the state to idle so that I can make another request (like you would
usually do by calling getresponse()).
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/http/client.py", line 1143, in getresponse
response.begin()
File "/usr/lib64/python3.3/http/client.py", line 354, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python3.3/http/client.py", line 324, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: ''Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.3/http/client.py", line 1061, in request
self._send_request(method, url, body, headers)
File "/usr/lib64/python3.3/http/client.py", line 1089, in _send_request
self.putrequest(method, url, **skips)
File "/usr/lib64/python3.3/http/client.py", line 944, in putrequest
raise CannotSendRequest(self.__state)
http.client.CannotSendRequest: Request-sent

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)

iQEcBAEBAgAGBQJSGyPCAAoJEK7pd0+nzJtNrY4H/0U1lVOupse+F7mWUUhcz9Dk
xBJ2XdxRUlVQK71872ulJWSDY84wAC+/xGj5Z6hXCbG/r/3H1RFIMmkLEmvkD9th
cFzle8OsLHeQLMb0gOFsd3ydFuMoGshtmFqzBdLtQF9KCP1V/F0EehKZ2c2y1NON
wQr8gsrkPK7HnYR+2wOTCnxObGgBglA5Lz0Rl1V+7e4Fbdn2sScsBFUdOWdBIrjI
6sqOQ76+AIMdDrGJuHchR/d3Qx02hvLk1txFukVFaZg9ZxgvZYAL23RuaBBFumvt
wvSsi1mgw+XpfzdRk8nW9bPY/iMMIKT/WR9CmXqgDM6lQ3iuceSuhprisn/4E/A=
=19JN
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top