Skip to content

Commit

Permalink
Merge pull request #79 from IGNF/fix/subprocess_returncode
Browse files Browse the repository at this point in the history
fix(subprocess): wait for process stop in case of None returncode
  • Loading branch information
azarz authored Mar 28, 2024
2 parents e580b63 + 8d4935f commit 256c72e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions r2gg/_subprocess_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 256c72e

Please sign in to comment.