8000 GH-100133: fix `asyncio` subprocess losing `stderr` and `stdout` output by kumaraditya303 · Pull Request #100154 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

GH-100133: fix asyncio subprocess losing stderr and stdout output #100154

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

Merged
merged 9 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add comment & test
  • Loading branch information
kumaraditya303 committed Dec 10, 2022
commit 6b9d8c17cb1a1a948a819e7bf1aa73296f4a86cf
5 changes: 4 additions & 1 deletion Lib/asyncio/base_subprocess.py
AC2B
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ def _process_exited(self, returncode):
# object. On Python 3.6, it is required to avoid a ResourceWarning.
self._proc.returncode = returncode
self._call(self._protocol.process_exited)
# See https://github.com/python/cpython/issues/100133
# The pipes should not be closed otherwise some data may be lost.
# https://github.com/python/cpython/issues/100133
# If the pipe is closed here then _UnixReadPipeTransport will remove the
# reader prematurely and the data will be lost, instead of doing that
# the pipe will be closed when the process is finished.
# for p in self._pipes.values():
# if p is not None:
# p.pipe.close()
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_asyncio/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ async def execute():
self.assertIsNone(self.loop.run_until_complete(execute()))

def test_subprocess_output_stdout(self):
# See https://github.com/python/cpython/issues/100133
async def get_command_stdout(cmd, *args):
proc = await asyncio.create_subprocess_exec(
cmd, *args, stdout=asyncio.subprocess.PIPE,
Expand Down
0