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


Groups > comp.lang.python > #52998

Resetting state of http.client/httplib HTTPSConnection objects

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <chris@chrisdown.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.060
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'ideally': 0.04; 'intermittent': 0.16; 'received:195.158': 0.16; 'suggestion.': 0.16; 'exception': 0.16; 'server,': 0.19; '>>>': 0.22; 'reset': 0.22; 'header:User-Agent:1': 0.23; 'body,': 0.24; 'from:addr:chris': 0.24; 'skip:" 30': 0.26; 'subject:/': 0.26; 'raise': 0.29; '(like': 0.30; 'usually': 0.31; '"",': 0.31; 'raised': 0.31; 'file': 0.32; 'skip:c 30': 0.32; 'another': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'connection': 0.35; 'idle': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'version,': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'entire': 0.61; 'content- disposition:inline': 0.62; 'getresponse': 0.84; 'subject:skip:H 10': 0.84; 'state.': 0.95
Date Mon, 26 Aug 2013 11:45:38 +0200
From Chris Down <chris@chrisdown.name>
To python-list@python.org
Subject Resetting state of http.client/httplib HTTPSConnection objects
MIME-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dCSxeJc5W8HZXZrD"
Content-Disposition inline
PGP-Key http://chrisdown.name/pgp
User-Agent Mutt/1.5.21 (2010-09-15)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.233.1377510343.19984.python-list@python.org> (permalink)
Lines 53
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377510344 news.xs4all.nl 15942 [2001:888:2000:d::a6]:47877
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52998

Show key headers only | View raw


[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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web