Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket leak if HTTPConnection.getresponse() fails #65231

Closed
vadmium opened this issue Mar 23, 2014 · 7 comments
Closed

Socket leak if HTTPConnection.getresponse() fails #65231

vadmium opened this issue Mar 23, 2014 · 7 comments
Assignees
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@vadmium
Copy link
Member

vadmium commented Mar 23, 2014

BPO 21032
Nosy @vadmium, @serhiy-storchaka, @fbidu
PRs
  • bpo-42060: Remove assert from http/client.py #22737
  • Files
  • test.patch
  • close.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2014-12-01.11:24:01.368>
    created_at = <Date 2014-03-23.04:05:47.742>
    labels = ['library', 'performance']
    title = 'Socket leak if HTTPConnection.getresponse() fails'
    updated_at = <Date 2020-10-23.19:09:49.466>
    user = 'https://github.com/vadmium'

    bugs.python.org fields:

    activity = <Date 2020-10-23.19:09:49.466>
    actor = 'fbidu'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2014-12-01.11:24:01.368>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2014-03-23.04:05:47.742>
    creator = 'martin.panter'
    dependencies = []
    files = ['34579', '34580']
    hgrepos = []
    issue_num = 21032
    keywords = ['patch']
    message_count = 7.0
    messages = ['214546', '231330', '231917', '231922', '231923', '231930', '231934']
    nosy_count = 4.0
    nosy_names = ['python-dev', 'martin.panter', 'serhiy.storchaka', 'fbidu']
    pr_nums = ['22737']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue21032'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @vadmium
    Copy link
    Member Author

    vadmium commented Mar 23, 2014

    Here is a regression test and patch to close the socket reader when a HTTP server causes getresponse() to fail, for instance if the server times out and drops the connection without sending any response. Without the patch the socket will only be closed by the garbage collector at some arbitrary point.

    @vadmium vadmium added stdlib Python modules in the Lib dir performance Performance or resource usage labels Mar 23, 2014
    @serhiy-storchaka
    Copy link
    Member

    Could you please submit a contributor form (https://www.python.org/psf/contrib/) Martin?

    @serhiy-storchaka serhiy-storchaka self-assigned this Nov 18, 2014
    @serhiy-storchaka
    Copy link
    Member

    What is the status of your contributor agreement Martin?

    @vadmium
    Copy link
    Member Author

    vadmium commented Dec 1, 2014

    Hi Serhiy, I submitted the form online on 22 Nov; just patiently waiting for it to come through now.

    In the last few minutes I noticed an asterisk has appeared against my name on the bug tracker, so hopefully it is all good now.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 1, 2014

    New changeset 561d1d0de518 by Serhiy Storchaka in branch 'default':
    Issue bpo-21032: Deprecated the use of re.LOCALE flag with str patterns or
    https://hg.python.org/cpython/rev/561d1d0de518

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 1, 2014

    New changeset f88c00391dd8 by Serhiy Storchaka in branch '2.7':
    Issue bpo-21032. Fixed socket leak if HTTPConnection.getresponse() fails.
    https://hg.python.org/cpython/rev/f88c00391dd8

    New changeset ba72da4883eb by Serhiy Storchaka in branch '3.4':
    Issue bpo-21032. Fixed socket leak if HTTPConnection.getresponse() fails.
    https://hg.python.org/cpython/rev/ba72da4883eb

    New changeset 62a058c76869 by Serhiy Storchaka in branch 'default':
    Issue bpo-21032. Fixed socket leak if HTTPConnection.getresponse() fails.
    https://hg.python.org/cpython/rev/62a058c76869

    @serhiy-storchaka
    Copy link
    Member

    Few notes about patches. Check patches for trailing spaces. And it would be more suitable if you provide single patch instead of a couple of patches. I have slightly changed the test, so it checks that the file is actually closed, not lost, The fix LGTM.

    Thank you for your contribution Martin.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants