From 9f60ba68f5b9b382ad714dcffccc99a8f8618cc7 Mon Sep 17 00:00:00 2001 From: Pere Miquel Brull Date: Mon, 21 Oct 2024 15:18:33 +0200 Subject: [PATCH] MINOR - Only timeout on main threads (#18341) --- ingestion/src/metadata/utils/timeout.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ingestion/src/metadata/utils/timeout.py b/ingestion/src/metadata/utils/timeout.py index effd93a65ff..54281c974fe 100644 --- a/ingestion/src/metadata/utils/timeout.py +++ b/ingestion/src/metadata/utils/timeout.py @@ -18,6 +18,7 @@ import inspect import os import platform import signal +import threading from typing import Callable from metadata.utils.constants import TEN_MIN @@ -47,7 +48,11 @@ def timeout(seconds: int = TEN_MIN) -> Callable: def decorator(fn): @functools.wraps(fn) def inner(*args, **kwargs): - if platform.system() != "Windows": # SIGALRM not supported on Windows + # SIGALRM is not supported on Windows or sub-threads + if ( + platform.system() != "Windows" + and threading.current_thread() == threading.main_thread() + ): signal.signal(signal.SIGALRM, _handle_timeout) signal.alarm(seconds) try: