Skip to content

Commit 101c9c0

Browse files
gh-118516: clarify that subprocess are automatically killed if transport gets garbage collected (#140997)
1 parent 95f6e12 commit 101c9c0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,9 @@ async/await code consider using the high-level
16311631
conforms to the :class:`asyncio.SubprocessTransport` base class and
16321632
*protocol* is an object instantiated by the *protocol_factory*.
16331633

1634+
If the transport is closed or is garbage collected, the child process
1635+
is killed if it is still running.
1636+
16341637
.. method:: loop.subprocess_shell(protocol_factory, cmd, *, \
16351638
stdin=subprocess.PIPE, stdout=subprocess.PIPE, \
16361639
stderr=subprocess.PIPE, **kwargs)
@@ -1654,6 +1657,9 @@ async/await code consider using the high-level
16541657
conforms to the :class:`SubprocessTransport` base class and
16551658
*protocol* is an object instantiated by the *protocol_factory*.
16561659

1660+
If the transport is closed or is garbage collected, the child process
1661+
is killed if it is still running.
1662+
16571663
.. note::
16581664
It is the application's responsibility to ensure that all whitespace
16591665
and special characters are quoted appropriately to avoid `shell injection

Doc/library/asyncio-subprocess.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ Creating Subprocesses
7676
See the documentation of :meth:`loop.subprocess_exec` for other
7777
parameters.
7878

79+
If the process object is garbage collected while the process is still
80+
running, the child process will be killed.
81+
7982
.. versionchanged:: 3.10
8083
Removed the *loop* parameter.
8184

@@ -95,6 +98,9 @@ Creating Subprocesses
9598
See the documentation of :meth:`loop.subprocess_shell` for other
9699
parameters.
97100

101+
If the process object is garbage collected while the process is still
102+
running, the child process will be killed.
103+
98104
.. important::
99105

100106
It is the application's responsibility to ensure that all whitespace and

0 commit comments

Comments
 (0)