This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: http.client doesn't close. Infinite loop
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, martin.panter, mdk, skorpeo
Priority: normal Keywords: patch, patch, patch, patch

Created on 2019-01-03 16:41 by skorpeo, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11441 merged python-dev, 2019-01-06 01:09
PR 11441 merged python-dev, 2019-01-06 01:09
PR 11441 merged python-dev, 2019-01-06 01:09
PR 11441 merged python-dev, 2019-01-06 01:09
PR 15930 merged miss-islington, 2019-09-11 12:42
PR 15931 merged miss-islington, 2019-09-11 12:42
Messages (6)
msg332934 - (view) Author: (skorpeo) Date: 2019-01-03 16:41
when testing example from https://docs.python.org/3/library/http.client.html.  Specifically the chunked example, i.e. while not r1.closed.  Results in infinite loop.  

I believe this is because line 398 function def _close_conn(self), should call self.close().
msg332947 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2019-01-03 20:21
This was changed in Python 3.2+ in Issue 16723. The response object no longer sets the “closed” attribute when it runs out of data; it is only set when the “close” method is called. Perhaps the example should be amended so that it checks if “read” returned an empty string, rather than checking “closed”.

Another problem with the example is that printing the chunk as a bytes object can trigger BytesWarning. I would add a “repr” call to avoid that.
msg332950 - (view) Author: (skorpeo) Date: 2019-01-03 22:07
Ha, ok that would explain it.  Yes, I think it would indeed be helpful to
update the example, but then again I guess leaving it as is may be a good
way to find out if people are reading the docs.

On Thu, Jan 3, 2019 at 10:21 PM Martin Panter <report@bugs.python.org>
wrote:

>
> Martin Panter <vadmium+py@gmail.com> added the comment:
>
> This was changed in Python 3.2+ in Issue 16723. The response object no
> longer sets the “closed” attribute when it runs out of data; it is only set
> when the “close” method is called. Perhaps the example should be amended so
> that it checks if “read” returned an empty string, rather than checking
> “closed”.
>
> Another problem with the example is that printing the chunk as a bytes
> object can trigger BytesWarning. I would add a “repr” call to avoid that.
>
> ----------
> assignee:  -> docs@python
> components: +Documentation
> nosy: +docs@python, martin.panter
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue35649>
> _______________________________________
>
msg351843 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2019-09-11 12:41
New changeset 62cf6981425c6a6b136c5e2abef853364f535e9d by Julien Palard (Ashwin Ramaswami) in branch 'master':
bpo-35649: update http client example (GH-11441)
https://github.com/python/cpython/commit/62cf6981425c6a6b136c5e2abef853364f535e9d
msg351851 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2019-09-11 13:02
New changeset 43fb3bb223338511a7aee9b55d75af4a415134dc by Julien Palard (Miss Islington (bot)) in branch '3.8':
bpo-35649: update http client example (GH-11441) (GH-15930)
https://github.com/python/cpython/commit/43fb3bb223338511a7aee9b55d75af4a415134dc
msg351858 - (view) Author: Julien Palard (mdk) * (Python committer) Date: 2019-09-11 13:13
New changeset 0fd8c0560b2099d2c976b17cf01cb596badc1ec6 by Julien Palard (Miss Islington (bot)) in branch '3.7':
bpo-35649: update http client example (GH-11441) (GH-15931)
https://github.com/python/cpython/commit/0fd8c0560b2099d2c976b17cf01cb596badc1ec6
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79830
2019-09-11 13:14:19mdksetkeywords: patch, patch, patch, patch
status: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-09-11 13:13:59mdksetmessages: + msg351858
2019-09-11 13:02:28mdksetmessages: + msg351851
2019-09-11 12:42:16miss-islingtonsetpull_requests: + pull_request15570
2019-09-11 12:42:09miss-islingtonsetpull_requests: + pull_request15569
2019-09-11 12:41:57mdksetnosy: + mdk
messages: + msg351843
2019-01-06 01:09:48python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request10886
2019-01-06 01:09:41python-devsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10887
2019-01-06 01:09:34python-devsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10885
2019-01-06 01:09:28python-devsetkeywords: + patch
stage: (no value)
pull_requests: + pull_request10884
2019-01-04 21:32:55terry.reedysetversions: + Python 3.8, - Python 3.5, Python 3.6
2019-01-03 22:07:33skorpeosetmessages: + msg332950
title: http.client doesn't close. Infinite loop -> http.client doesn't close. Infinite loop
2019-01-03 20:21:41martin.pantersetnosy: + docs@python, martin.panter
messages: + msg332947

assignee: docs@python
components: + Documentation
2019-01-03 16:45:41skorpeosettype: behavior
2019-01-03 16:41:48skorpeocreate