From af2fc8c111e1043c798d6cd67512ff942f8feaa8 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 14 May 2023 13:58:50 +0800 Subject: [PATCH] Use proc.communicate() when checking for subprocess output As recommended in https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.subprocess.Process.stderr --- gns3server/utils/asyncio/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gns3server/utils/asyncio/__init__.py b/gns3server/utils/asyncio/__init__.py index d459cb18..efc32d06 100644 --- a/gns3server/utils/asyncio/__init__.py +++ b/gns3server/utils/asyncio/__init__.py @@ -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