Skip to content

Commit ceaa4d1

Browse files
authored
Take down all processes if one finishes. (opencv#51)
Signed-off-by: Tully Foote <[email protected]>
1 parent d916ee6 commit ceaa4d1

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

ibpc_py/src/ibpc/ibpc.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import shlex
55
import shutil
6+
import signal
67
import threading
78
import subprocess
89

@@ -250,20 +251,9 @@ def main():
250251
print("Build of zenoh failed exiting")
251252
return exit_code
252253

253-
def run_instance(dig_instance, args):
254-
dig_instance.run(**args)
255-
256254
print("Making sure that containers are not left over from previous runs. ")
257255
stop_containers(quiet=True)
258256

259-
zenoh_thread = threading.Thread(target=run_instance, args=(dig_zenoh, zenoh_args))
260-
zenoh_thread.start()
261-
262-
tester_thread = threading.Thread(
263-
target=run_instance, args=(dig_tester, tester_args)
264-
)
265-
tester_thread.start()
266-
267257
args_dict["name"] = ESTIMATOR_CONTAINER
268258
args_dict["network"] = "host"
269259
args_dict["extension_blacklist"] = ({},)
@@ -288,8 +278,28 @@ def run_instance(dig_instance, args):
288278
args_dict["command"] = "/bin/bash"
289279
args_dict["mode"] = OPERATIONS_INTERACTIVE
290280

281+
def run_instance(dig_instance, args, other_instances):
282+
result = dig_instance.run(**args)
283+
name = args["name"]
284+
print(f"{ name } finished with exit code {result} -- stopping others.")
285+
stop_containers(other_instances, quiet=True)
286+
287+
zenoh_thread = threading.Thread(
288+
target=run_instance,
289+
args=(dig_zenoh, zenoh_args, [TESTER_CONTAINER, ESTIMATOR_CONTAINER]),
290+
)
291+
zenoh_thread.start()
292+
293+
tester_thread = threading.Thread(
294+
target=run_instance,
295+
args=(dig_tester, tester_args, [ZENOH_CONTAINER, ESTIMATOR_CONTAINER]),
296+
)
297+
tester_thread.start()
298+
291299
try:
292300
result = dig.run(**args_dict)
301+
print(f"Estimator finished with exit code {result}")
302+
stop_containers(quiet=True)
293303
return result
294304

295305
except KeyboardInterrupt:

0 commit comments

Comments
 (0)