mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix: only call signal if executing on the main thread (#10677)
This commit is contained in:
parent
502f4db6f9
commit
a6101f72c9
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user