From 7bd3ef40d433202735cc4905fcefaf63478dee1a Mon Sep 17 00:00:00 2001 From: Fernando Celmer Date: Tue, 7 Apr 2026 00:09:15 -0300 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=AA=B2=20BUG-#131:=20Fix=20timeout=20?= =?UTF-8?q?thread=20leak=20by=20using=20shutdown(wait=3DFalse,=20cancel=5F?= =?UTF-8?q?futures=3DTrue)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotflow/core/action.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dotflow/core/action.py b/dotflow/core/action.py index a75227dd..9e25d486 100644 --- a/dotflow/core/action.py +++ b/dotflow/core/action.py @@ -144,7 +144,8 @@ def _run_action(self, *args, task=None, **kwargs): for attempt in range(1, self.retry + 1): try: if self.timeout: - with ThreadPoolExecutor(max_workers=1) as executor: + executor = ThreadPoolExecutor(max_workers=1) + try: future = executor.submit( self._call_func, is_async, @@ -152,6 +153,12 @@ def _run_action(self, *args, task=None, **kwargs): **kwargs, ) result = future.result(timeout=self.timeout) + except TimeoutError: + future.cancel() + executor.shutdown(wait=False, cancel_futures=True) + raise + else: + executor.shutdown(wait=False) else: result = self._call_func(is_async, *args, **kwargs) From 4898957543344b64894b7ee75b28a4733b7a6898 Mon Sep 17 00:00:00 2001 From: Fernando Celmer Date: Tue, 7 Apr 2026 00:21:01 -0300 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=AA=B2=20BUG-#131:=20Prevent=20thread?= =?UTF-8?q?=20pileup=20by=20not=20retrying=20on=20TimeoutError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotflow/core/action.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dotflow/core/action.py b/dotflow/core/action.py index 9e25d486..37c91725 100644 --- a/dotflow/core/action.py +++ b/dotflow/core/action.py @@ -164,6 +164,9 @@ def _run_action(self, *args, task=None, **kwargs): return result + except TimeoutError: + raise + except Exception as error: last_exception = error From 67587ad7b9ad7284a9209142c65058f1c4ed3ecb Mon Sep 17 00:00:00 2001 From: Fernando Celmer Date: Tue, 7 Apr 2026 00:22:29 -0300 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=AA=B2=20BUG-#131:=20Shutdown=20execu?= =?UTF-8?q?tor=20on=20task=20exception=20to=20prevent=20resource=20leak?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dotflow/core/action.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dotflow/core/action.py b/dotflow/core/action.py index 37c91725..62710a3a 100644 --- a/dotflow/core/action.py +++ b/dotflow/core/action.py @@ -157,6 +157,9 @@ def _run_action(self, *args, task=None, **kwargs): future.cancel() executor.shutdown(wait=False, cancel_futures=True) raise + except Exception: + executor.shutdown(wait=False) + raise else: executor.shutdown(wait=False) else: