From a6101f72c96d89e3fbf9999f16cf3b5147f73d8f Mon Sep 17 00:00:00 2001 From: henryyeh Date: Tue, 25 Aug 2020 16:57:58 -0700 Subject: [PATCH] fix: only call signal if executing on the main thread (#10677) --- superset/utils/core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/superset/utils/core.py b/superset/utils/core.py index aa3a10a7b..5ccb74aa9 100644 --- a/superset/utils/core.py +++ b/superset/utils/core.py @@ -26,6 +26,7 @@ import re import signal import smtplib import tempfile +import threading import traceback import uuid import zlib @@ -631,8 +632,9 @@ class timeout: # pylint: disable=invalid-name 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)