diff options
author | Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> | 2023-04-28 00:30:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-28 00:30:26 (GMT) |
commit | 67d140dba72dc2cb661d55878384464de46719e7 (patch) | |
tree | f9459ce8747f0910eb8e62c9c175801378e3175f /Lib/test/test_asyncio | |
parent | 424a785a07049924603228b153f746cfe3a983a2 (diff) | |
download | cpython-67d140dba72dc2cb661d55878384464de46719e7.zip cpython-67d140dba72dc2cb661d55878384464de46719e7.tar.gz cpython-67d140dba72dc2cb661d55878384464de46719e7.tar.bz2 |
gh-83925: Make asyncio.subprocess communicate similar to non-asyncio (#18650)
subprocess's communicate(None) closes stdin of the child process, after
sending no (extra) data. Make asyncio variant do the same.
This fixes issues with processes that waits for EOF on stdin before
continuing.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_subprocess.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py index eba6e2d..eeeca40 100644 --- a/Lib/test/test_asyncio/test_subprocess.py +++ b/Lib/test/test_asyncio/test_subprocess.py @@ -151,6 +151,24 @@ class SubprocessMixin: self.assertEqual(exitcode, 0) self.assertEqual(stdout, b'some data') + def test_communicate_none_input(self): + args = PROGRAM_CAT + + async def run(): + proc = await asyncio.create_subprocess_exec( + *args, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + stdout, stderr = await proc.communicate() + return proc.returncode, stdout + + task = run() + task = asyncio.wait_for(task, support.LONG_TIMEOUT) + exitcode, stdout = self.loop.run_until_complete(task) + self.assertEqual(exitcode, 0) + self.assertEqual(stdout, b'') + def test_shell(self): proc = self.loop.run_until_complete( asyncio.create_subprocess_shell('exit 7') |