Skip to content
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
Next Next commit
wip
  • Loading branch information
kumaraditya303 committed Dec 10, 2022
commit b980b7f1078232efba5ee55baf5c2e05f9784f60
8 changes: 5 additions & 3 deletions Lib/asyncio/base_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +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)
for p in self._pipes.values():
if p is not None:
p.pipe.close()
# The pipes should not be closed otherwise some data may be lost.
# https://github.com/python/cpython/issues/100133
# for p in self._pipes.values():
# if p is not None:
# p.pipe.close()
Comment thread
kumaraditya303 marked this conversation as resolved.
Outdated

self._try_finish()

Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_asyncio/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,21 @@ async def execute():

self.assertIsNone(self.loop.run_until_complete(execute()))

def test_subprocess_output_stdout(self):
async def get_command_stdout(cmd, *args):
proc = await asyncio.create_subprocess_exec(
cmd, *args, stdout=asyncio.subprocess.PIPE,
)
stdout, _ = await proc.communicate()
return stdout.decode().strip()

async def main():
outputs = [f'foo{i}' for i in range(10)]
Comment thread
gvanrossum marked this conversation as resolved.
res = await asyncio.gather(*[get_command_stdout('echo', out) for out in outputs])
self.assertEqual(res, outputs)

self.loop.run_until_complete(main())


if sys.platform != 'win32':
# Unix
Expand Down