Skip to content

Commit

Permalink
EXPERIMENT 1 try catch log and finally join thread
Browse files Browse the repository at this point in the history
  • Loading branch information
asmacdo committed Sep 10, 2024
1 parent a6637ed commit 9180f89
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,14 @@ def runner() -> int:
thread.start()
sleep(0.01) # make sure the process is started
ps_command = "ps aux | grep '[s]leep 60.74016230000801'" # brackets to not match grep process
ps_output = subprocess.check_output(ps_command, shell=True).decode()
pid = int(ps_output.split()[1])
os.kill(pid, signal.SIGTERM)

thread.join()
try:
ps_output = subprocess.check_output(ps_command, shell=True).decode()
pid = int(ps_output.split()[1])
os.kill(pid, signal.SIGTERM)
except subprocess.CalledProcessError as e:
pytest.fail(f"ps failed for some reason: {e}")
finally:
thread.join()
# Cannot retrieve the exit code from the thread, it is written to the file
with open(os.path.join(temp_output_dir, SUFFIXES["info"])) as info:
info_data = json.loads(info.read())
Expand Down

0 comments on commit 9180f89

Please sign in to comment.