diff --git a/superset/utils/core.py b/superset/utils/core.py index aa3a10a7b9ffd..5ccb74aa99fa1 100644 --- a/superset/utils/core.py +++ b/superset/utils/core.py @@ -26,6 +26,7 @@ import signal import smtplib import tempfile +import threading import traceback import uuid import zlib @@ -631,8 +632,9 @@ def handle_timeout( # pylint: disable=unused-argument def __enter__(self) -> None: try: - signal.signal(signal.SIGALRM, self.handle_timeout) - signal.alarm(self.seconds) + if threading.current_thread() == threading.main_thread(): + signal.signal(signal.SIGALRM, self.handle_timeout) + signal.alarm(self.seconds) except ValueError as ex: logger.warning("timeout can't be used in the current context") logger.exception(ex)