Skip to content

Commit

Permalink
fix: only call signal if executing on the main thread (apache#10677)
Browse files Browse the repository at this point in the history
  • Loading branch information
henryyeh authored and auxten committed Nov 20, 2020
1 parent 54418a1 commit 9e0f41b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import signal
import smtplib
import tempfile
import threading
import traceback
import uuid
import zlib
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9e0f41b

Please sign in to comment.