This is an automated email from the ASF dual-hosted git repository.

villebro pushed a commit to branch 0.38
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit f66a412557ca9bfe739b6ee3568fa5104648042b
Author: henryyeh <[email protected]>
AuthorDate: Tue Aug 25 16:57:58 2020 -0700

    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 aa3a10a..5ccb74a 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)

Reply via email to