Merge pull request #2223 from GNS3/fix/2214

Use proc.communicate() when checking for subprocess output
This commit is contained in:
Jeremy Grossmann authored and GitHub committed 2023-06-02 20:29:40 +09:30
commit 088ae699de
2 files changed
+11 -4

No files matched your search

+2 -2
View File
@@ -71,10 +71,10 @@ async def subprocess_check_output(*args, cwd=None, env=None, stderr=False):
if stderr:
proc = await asyncio.create_subprocess_exec(*args, stderr=asyncio.subprocess.PIPE, cwd=cwd, env=env)
output = await proc.stderr.read()
_, output = await proc.communicate()
else:
proc = await asyncio.create_subprocess_exec(*args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.DEVNULL, cwd=cwd, env=env)
output = await proc.stdout.read()
output, _ = await proc.communicate()
if output is None:
return ""
# If we received garbage we ignore invalid characters