Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52998 > unrolled thread

Resetting state of http.client/httplib HTTPSConnection objects

Started byChris Down <chris@chrisdown.name>
First post2013-08-26 11:45 +0200
Last post2013-08-26 11:45 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Resetting state of http.client/httplib HTTPSConnection objects Chris Down <chris@chrisdown.name> - 2013-08-26 11:45 +0200

#52998 — Resetting state of http.client/httplib HTTPSConnection objects

FromChris Down <chris@chrisdown.name>
Date2013-08-26 11:45 +0200
SubjectResetting state of http.client/httplib HTTPSConnection objects
Message-ID<mailman.233.1377510343.19984.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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()).

    >>> a.conn
    <http.client.HTTPSConnection object at 0x7f8d7cb58bd0>
    >>> a.conn.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: ''
    >>> a.conn.request("GET", "foo")
    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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web