Skip to content

asyncio: Process must close the transport when the process exit #67431

Closed

Description

@vstinner
BPO 23242
Nosy @gvanrossum, @vstinner, @agronholm, @1st1
Files
  • subprocess_close.patch
  • read_subprocess.py
  • 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 = None
    closed_at = <Date 2015-01-15.13:36:57.010>
    created_at = <Date 2015-01-14.23:11:18.655>
    labels = ['expert-asyncio']
    title = 'asyncio: Process must close the transport when the process exit'
    updated_at = <Date 2017-01-07.19:58:07.672>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-01-07.19:58:07.672>
    actor = 'alex.gronholm'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-01-15.13:36:57.010>
    closer = 'vstinner'
    components = ['asyncio']
    creation = <Date 2015-01-14.23:11:18.655>
    creator = 'vstinner'
    dependencies = []
    files = ['37707', '46198']
    hgrepos = []
    issue_num = 23242
    keywords = ['patch']
    message_count = 4.0
    messages = ['234042', '234070', '234075', '284930']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'vstinner', 'alex.gronholm', 'python-dev', 'yselivanov']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue23242'
    versions = ['Python 3.4', 'Python 3.5', 'Python 3.6']

    Activity

    1. vstinner commented on Jan 14, 2015

      @vstinner
      MemberAuthor

      The asyncio.subprocess.Process class never closes the subprocess transport, whereas this transport is private.

      I propose to close the transport as soon as possible: when transport.get_returncode() is called and its result is not None.

      I'm not sure that it's the most efficient way to close the transport. It may be better to close the transport in the connection_lost() method of the protocol.

      The patch also checks in Process.communicate() that the process is alive, and is clears the reference to the transport.

    2. python-dev commented on Jan 15, 2015

      python-devmannequin
      Mannequin

      New changeset df493e9c6821 by Victor Stinner in branch '3.4':
      Issue bpo-23242: asyncio.SubprocessStreamProtocol now closes the subprocess
      https://hg.python.org/cpython/rev/df493e9c6821

    3. vstinner commented on Jan 15, 2015

      @vstinner
      MemberAuthor

      I'm not sure that it's the most efficient way to close the transport. It may be better to close the transport in the connection_lost() method of the protocol.

      "process_exited", not "connection_lost".

      I implemented this option which is simpler and more efficient (always and immediatly close the transport).

      Clearing the reference to the transport in the Process is less important, it can be done later in a different issue/changeset. I close this issue.

    4. agronholm commented on Jan 7, 2017

      agronholmmannequin
      Mannequin

      Are you sure this has been fixed? The attached script reproduces the bug 100% reliably on my laptop.

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions