fix handling of run interruption
We waited for all worker threads to terminate in stop(),
but in rare cases the stop() method could be executed in one of the
worker threads (as a signal handler), and then the attempt to join the
current thread would fail.
Now we wait in the main thread.
@@ -233,6 +233,10 @@ def execute_benchmark(benchmark, output_handler):
lambda: unfinished_runs == 0 or STOPPED_BY_INTERRUPT
)
+ # wait until all runs are finished
+ for worker in WORKER_THREADS:
+ worker.join()
+
# get times after runSet
walltime_after = util.read_monotonic_time()
energy = energy_measurement.stop() if energy_measurement else None
@@ -278,10 +282,6 @@ def stop():
for worker in WORKER_THREADS:
worker.stop()
- # wait until all threads are stopped
- for worker in WORKER_THREADS:
- worker.join()
-
# wake up main thread
with FINISHED_NOTIFICATION:
FINISHED_NOTIFICATION.notify()
