From 625df7982d22b83ee0dcf35550999111408b4d0b Mon Sep 17 00:00:00 2001 From: KenADev Date: Sun, 26 Oct 2025 20:47:23 +0100 Subject: [PATCH] feat: Mesh-Ingestor: Ability to provide already-existing interface instance (#395) * feat: Mesh-Ingestor: Ability to provide already-existing interface instance * Prevent Signal-Registration if not main thread (causes exception) * fix redundant ternary operator --------- Co-authored-by: Ken Ahr --- data/mesh_ingestor/daemon.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/mesh_ingestor/daemon.py b/data/mesh_ingestor/daemon.py index 8ecf950..25f6a2f 100644 --- a/data/mesh_ingestor/daemon.py +++ b/data/mesh_ingestor/daemon.py @@ -206,7 +206,7 @@ def _connected_state(candidate) -> bool | None: return None -def main() -> None: +def main(existing_interface=None) -> None: """Run the mesh ingestion daemon until interrupted.""" subscribed = _subscribe_receive_topics() @@ -218,7 +218,7 @@ def main() -> None: topics=subscribed, ) - iface = None + iface = existing_interface resolved_target = None retry_delay = max(0.0, config._RECONNECT_INITIAL_DELAY_SECS) @@ -254,8 +254,9 @@ def main() -> None: return stop.set() - signal.signal(signal.SIGINT, handle_sigint) - signal.signal(signal.SIGTERM, handle_sigterm) + if threading.current_thread() == threading.main_thread(): + signal.signal(signal.SIGINT, handle_sigint) + signal.signal(signal.SIGTERM, handle_sigterm) target = config.INSTANCE or "(no POTATOMESH_INSTANCE)" configured_port = config.CONNECTION