[elbe-devel] [PATCH 04/11] elbepack: initvm: suppress subprocess ResourceWarning

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Aug 8 11:38:15 CEST 2024


For our usecase this warning is a false-positive.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/initvm.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/elbepack/initvm.py b/elbepack/initvm.py
index 9c8973bd99c7..74102bf6ba29 100644
--- a/elbepack/initvm.py
+++ b/elbepack/initvm.py
@@ -53,6 +53,13 @@ def _test_soap_communication(port, sleep=10, wait=120):
         time.sleep(sleep)
 
 
+def _run_and_detach(*args, **kwargs):
+    ps = subprocess.Popen(*args, **kwargs)
+    # When a process object is not wait()ed for, the subprocess module raises a ResourceWarning.
+    # Inhibit this warning, as for our usecase it is not a problem.
+    ps.returncode = 0
+
+
 def _build_initvm(directory):
     try:
         subprocess.run(['make'], cwd=directory, check=True)
@@ -334,7 +341,7 @@ class QemuInitVM(_InitVM):
         else:
             # Try to start the QEMU VM for the given directory.
             try:
-                subprocess.Popen(['make', 'run_qemu'], cwd=initvmdir)
+                _run_and_detach(['make', 'run_qemu'], cwd=initvmdir)
             except Exception as e:
                 raise with_cli_details(e, 211, 'Running QEMU failed')
 

-- 
2.46.0



More information about the elbe-devel mailing list