Skip to content

Commit b597a93

Browse files
committed
profiler: handle deaadlocks caused by closing profiler queues before joining the profiler threads
1 parent fcc35ac commit b597a93

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

slips_files/core/profiler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,14 @@ def should_stop(self):
664664
return False
665665

666666
def shutdown_gracefully(self):
667-
# signal the threads to stop
668667
self.stop_profiler_threads.set()
668+
# wait for all flows to be processed by the profiler threads.
669+
self.join_profiler_threads()
670+
# close the queues to avoid deadlocks.
671+
# this step SHOULD NEVER be done before closing the threads
669672
self.flows_to_process_q.close()
670673
self.profiler_queue.close()
671-
# wait for them to finish
672-
self.join_profiler_threads()
674+
673675
self.db.set_new_incoming_flows(False)
674676
self.print(
675677
f"Stopping. Total lines read: {self.rec_lines}",

0 commit comments

Comments
 (0)