Skip to content

Commit 2936fc3

Browse files
committed
Fix signal handler flood: only install in main process
setup_signal_handlers() was being called in every ruffus worker subprocess (each one inherits the parent's handler via fork). When the pipeline exits and SIGTERM is broadcast to the process group, every worker logs 'Received signal 15. Starting clean-up.' and runs cleanup in parallel, producing dozens of duplicate log lines. Fix: skip handler installation in non-main processes using multiprocessing.current_process().name.
1 parent 98e72f1 commit 2936fc3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cgatcore/pipeline/execution.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,15 @@ def cleanup_all_jobs(self):
923923
self.active_jobs.clear() # Clear the list after cleanup
924924

925925
def setup_signal_handlers(self):
926-
"""Set up signal handlers to clean up jobs on SIGINT and SIGTERM."""
926+
"""Set up signal handlers to clean up jobs on SIGINT and SIGTERM.
927+
928+
Only installed in the main process; ruffus worker subprocesses inherit
929+
signal dispositions from the parent but should not run cleanup themselves,
930+
otherwise every worker logs the signal and tries to clean up in parallel.
931+
"""
932+
import multiprocessing
933+
if multiprocessing.current_process().name != 'MainProcess':
934+
return
927935

928936
def signal_handler(signum, frame):
929937
self.logger.info(f"Received signal {signum}. Starting clean-up.")

0 commit comments

Comments
 (0)