From 8d4935f150a235feae03018981ff8f0393b02a82 Mon Sep 17 00:00:00 2001 From: jmkerloch Date: Thu, 28 Mar 2024 10:22:28 +0100 Subject: [PATCH] fix(subprocess): wait for process stop in case of None returncode --- changelog.md | 5 +++++ r2gg/_subprocess_execution.py | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 405ad6b..60edc8d 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,11 @@ ## x.y.z +## 2.2.6 + +FIXED: +- subprocess : None value can be returned as returncode. Need to wait for process stop in this case + ## 2.2.5 CHANGED: diff --git a/r2gg/_subprocess_execution.py b/r2gg/_subprocess_execution.py index d2817b5..84e26ac 100644 --- a/r2gg/_subprocess_execution.py +++ b/r2gg/_subprocess_execution.py @@ -33,9 +33,12 @@ def subprocess_execution(args, logger, outfile = None): process_output, _ = process.communicate() logger.info(process_output.decode("utf-8")) - returncode = process.returncode + # Wait for process stop + while process.returncode is None: + process.wait() + if process.returncode != 0: - error_msg = f"Invalid returncode {returncode} for subprocess '{subprocess_arg}'" + error_msg = f"Invalid returncode {process.returncode} for subprocess '{subprocess_arg}'" logger.error(error_msg) raise RuntimeError(error_msg)