From c6f6930c2720c372d744b1ce3bef1ca66fb8e1ef Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Tue, 22 Jul 2025 17:24:07 -0300 Subject: [PATCH 1/2] Adding support for handle_sigterm --- src/pipecat/pipeline/runner.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pipecat/pipeline/runner.py b/src/pipecat/pipeline/runner.py index d64bf9495..2f3a8d7de 100644 --- a/src/pipecat/pipeline/runner.py +++ b/src/pipecat/pipeline/runner.py @@ -38,14 +38,16 @@ class PipelineRunner(BaseObject): handle_sigint: bool = True, force_gc: bool = False, loop: Optional[asyncio.AbstractEventLoop] = None, + handle_sigterm: bool = False, ): """Initialize the pipeline runner. Args: name: Optional name for the runner instance. - handle_sigint: Whether to automatically handle SIGINT/SIGTERM signals. + handle_sigint: Whether to automatically handle SIGINT signals. force_gc: Whether to force garbage collection after task completion. loop: Event loop to use. If None, uses the current running loop. + handle_sigterm: Whether to automatically handle SIGTERM signals. """ super().__init__(name=name) @@ -57,6 +59,9 @@ class PipelineRunner(BaseObject): if handle_sigint: self._setup_sigint() + if handle_sigterm: + self._setup_sigterm() + async def run(self, task: PipelineTask): """Run a pipeline task to completion. @@ -96,6 +101,10 @@ class PipelineRunner(BaseObject): """Set up signal handlers for graceful shutdown.""" loop = asyncio.get_running_loop() loop.add_signal_handler(signal.SIGINT, lambda *args: self._sig_handler()) + + def _setup_sigterm(self): + """Set up signal handlers for graceful shutdown.""" + loop = asyncio.get_running_loop() loop.add_signal_handler(signal.SIGTERM, lambda *args: self._sig_handler()) def _sig_handler(self): From 7d527c3a6b1419b06079e6d38a4047fec7f6b374 Mon Sep 17 00:00:00 2001 From: Filipi Fuchter Date: Tue, 22 Jul 2025 19:32:52 -0300 Subject: [PATCH 2/2] Mentioning the new field in the changelog. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0b6966d..d59a85c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added a new field `handle_sigterm` to `PipelineRunner`. It defaults to `False`. + This field handles SIGTERM signals. The `handle_sigint` field still defaults + to `True`, but now it handles only SIGINT signals. + - Added foundational example `14u-function-calling-ollama.py` for Ollama function calling.