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

Reader of BufferedRWPair is not closed if writer's close() fails #66001

Closed
serhiy-storchaka opened this issue Jun 18, 2014 · 6 comments
Closed
Assignees
Labels
topic-IO type-bug An unexpected behavior, bug, or error

Comments

@serhiy-storchaka
Copy link
Member

BPO 21802
Nosy @pitrou, @benjaminp, @vadmium, @serhiy-storchaka
Files
  • bufferedrwpair_close.patch
  • bufferedrwpair_close_2.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 2015-03-24.21:24:54.269>
    created_at = <Date 2014-06-18.17:52:22.071>
    labels = ['type-bug', 'expert-IO']
    title = "Reader of BufferedRWPair is not closed if writer's close() fails"
    updated_at = <Date 2015-03-24.21:24:54.268>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-03-24.21:24:54.268>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-03-24.21:24:54.269>
    closer = 'serhiy.storchaka'
    components = ['IO']
    creation = <Date 2014-06-18.17:52:22.071>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['35684', '37271']
    hgrepos = []
    issue_num = 21802
    keywords = ['patch']
    message_count = 6.0
    messages = ['220945', '224000', '231595', '231641', '234268', '239182']
    nosy_count = 6.0
    nosy_names = ['pitrou', 'benjamin.peterson', 'stutzbach', 'python-dev', 'martin.panter', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21802'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @serhiy-storchaka
    Copy link
    Member Author

    Current implementation of BufferedRWPair.close() is:

        def close(self):
            self.writer.close()
            self.reader.close()

    When self.writer.close() raises an exception, self.reader left non-closed. This can cause file description leak unless GC sweep it.

    Proposed patch fixes this issue. With applied patch for bpo-21715 it would be a little simpler.

    @serhiy-storchaka serhiy-storchaka added topic-IO type-bug An unexpected behavior, bug, or error labels Jun 18, 2014
    @serhiy-storchaka
    Copy link
    Member Author

    Antoine, what do you think about this?

    @pitrou
    Copy link
    Member

    pitrou commented Nov 24, 2014

    Why don't you reuse the API from bpo-21715?

    @serhiy-storchaka
    Copy link
    Member Author

    Because this API was not still committed. Here is a patch which uses it.

    @serhiy-storchaka
    Copy link
    Member Author

    Ping.

    If this patch will be accepted I'll provide larger patch for similar issues in close methods of other classes.

    @serhiy-storchaka serhiy-storchaka self-assigned this Mar 24, 2015
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 24, 2015

    New changeset d4694c672c36 by Serhiy Storchaka in branch '3.4':
    Issue bpo-21802: The reader in BufferedRWPair now is closed even when closing
    https://hg.python.org/cpython/rev/d4694c672c36

    New changeset f515c7ccff57 by Serhiy Storchaka in branch 'default':
    Issue bpo-21802: The reader in BufferedRWPair now is closed even when closing
    https://hg.python.org/cpython/rev/f515c7ccff57

    New changeset dcf25060cae8 by Serhiy Storchaka in branch '2.7':
    Issue bpo-21802: The reader in BufferedRWPair now is closed even when closing
    https://hg.python.org/cpython/rev/dcf25060cae8

    @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
    topic-IO type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants