mirror of
https://github.com/apache/superset.git
synced 2026-04-07 18:35:15 +00:00
fix: only call signal if executing on the main thread (#10677)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user