From 5f7f415e0dbe6856eeaffca251ea46acbac24588 Mon Sep 17 00:00:00 2001 From: Rob Jarawan <32302742+robjarawan@users.noreply.github.com> Date: Sun, 29 Mar 2026 21:44:31 -0400 Subject: [PATCH] Remove SIGTERM handler override in AM gather and send plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both gather/am.py and send/am.py override SIGTERM with SIG_DFL in __init__, which kills the process immediately on stop/restart. This bypasses the flow's graceful shutdown — on_stop callbacks, message acking, and connection cleanup are all skipped. Remove the override so the parent flow's signal handler runs properly. --- sarracenia/flowcb/gather/am.py | 7 +++---- sarracenia/flowcb/send/am.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sarracenia/flowcb/gather/am.py b/sarracenia/flowcb/gather/am.py index 4eeab64d1..40c37274c 100644 --- a/sarracenia/flowcb/gather/am.py +++ b/sarracenia/flowcb/gather/am.py @@ -64,7 +64,7 @@ André LeBlanc, ANL, Autumn 2022 """ -import logging, socket, struct, time, sys, os, signal, ipaddress, urllib.parse, getpass, psutil +import logging, socket, struct, time, sys, os, ipaddress, urllib.parse, getpass, psutil import re from base64 import b64encode from random import randint @@ -113,9 +113,8 @@ def __init__(self, options): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - # Add signal handler - ## Override outer signal handler with a default one to exit correctly. - signal.signal(signal.SIGTERM, signal.SIG_DFL) + # Let the parent flow's signal handler manage graceful shutdown. + # Previously overrode with SIG_DFL which bypassed all cleanup. def __WaitForRemoteConnections__(self) -> NoReturn: diff --git a/sarracenia/flowcb/send/am.py b/sarracenia/flowcb/send/am.py index 297751a9b..cd5bf80bc 100644 --- a/sarracenia/flowcb/send/am.py +++ b/sarracenia/flowcb/send/am.py @@ -32,7 +32,7 @@ André LeBlanc, ANL, Autumn 2022 """ -import logging, socket, struct, time, signal, sys, os +import logging, socket, struct, time, sys, os import urllib.parse from sarracenia.flowcb import FlowCB @@ -63,9 +63,8 @@ def __init__(self, options): self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 2) - # Add signal handler - ## Override outer signal handler with a default one to exit correctly. - signal.signal(signal.SIGTERM, signal.SIG_DFL) + # Let the parent flow's signal handler manage graceful shutdown. + # Previously overrode with SIG_DFL which bypassed all cleanup. def wrapbulletin(self, sarra_msg):