[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/10] python/machine: use subprocess.run instead of subprocess.P
From: |
John Snow |
Subject: |
[PATCH 03/10] python/machine: use subprocess.run instead of subprocess.Popen |
Date: |
Wed, 12 May 2021 17:46:35 -0400 |
use run() instead of Popen() -- to assert to pylint that we are not
forgetting to close a long-running program.
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/machine.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/python/qemu/machine.py b/python/qemu/machine.py
index 41f51bd27d0..c13ff9b32bf 100644
--- a/python/qemu/machine.py
+++ b/python/qemu/machine.py
@@ -223,13 +223,16 @@ def send_fd_scm(self, fd: Optional[int] = None,
assert fd is not None
fd_param.append(str(fd))
- proc = subprocess.Popen(
- fd_param, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, close_fds=False
+ proc = subprocess.run(
+ fd_param,
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ check=True,
+ close_fds=False,
)
- output = proc.communicate()[0]
- if output:
- LOG.debug(output)
+ if proc.stdout:
+ LOG.debug(proc.stdout)
return proc.returncode
--
2.30.2
- [PATCH 00/10] Python: delint iotests, machine.py and console_socket.py, John Snow, 2021/05/12
- [PATCH 01/10] python/console_socket: avoid one-letter variable, John Snow, 2021/05/12
- [PATCH 03/10] python/machine: use subprocess.run instead of subprocess.Popen,
John Snow <=
- [PATCH 04/10] python/console_socket: Add a pylint ignore, John Snow, 2021/05/12
- [PATCH 08/10] iotests: use 'with open()' where applicable, John Snow, 2021/05/12
- [PATCH 06/10] python/machine: disable warning for Popen in _launch(), John Snow, 2021/05/12
- [PATCH 09/10] iotests: silence spurious consider-using-with warnings, John Snow, 2021/05/12
- [PATCH 07/10] iotests: use subprocess.run where possible, John Snow, 2021/05/12