diff options
author | Jürg Billeter <j@bitron.ch> | 2018-05-21 11:29:54 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-07-08 14:33:46 +0200 |
commit | c5fe94650fd40360400624888492ff81e993eab4 (patch) | |
tree | 9fea42eb62302ac11b2c9b4e0ce87504a2458d7d | |
parent | 9067e269a9f2866e659ef33a69aad72b01cb6633 (diff) | |
download | buildstream-c5fe94650fd40360400624888492ff81e993eab4.tar.gz |
_signals.py: Guard against use in non-main thread
-rw-r--r-- | buildstream/_signals.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/buildstream/_signals.py b/buildstream/_signals.py index f1e520d37..0035485a5 100644 --- a/buildstream/_signals.py +++ b/buildstream/_signals.py @@ -19,6 +19,7 @@ import os import signal import sys +import threading import traceback from contextlib import contextmanager, ExitStack from collections import deque @@ -71,6 +72,11 @@ def terminator_handler(signal_, frame): def terminator(terminate_func): global terminator_stack # pylint: disable=global-statement + # Signal handling only works in the main thread + if threading.current_thread() != threading.main_thread(): + yield + return + outermost = False if terminator_stack else True terminator_stack.append(terminate_func) |