You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:11:39 UTC

[buildstream] 30/41: _signals.py: Guard against use in non-main thread

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

github-bot pushed a commit to branch jmac/googlecas_and_virtual_directories_1
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 71136a6edbf8cf58922248606b4edc6c1263b561
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Mon May 21 11:29:54 2018 +0200

    _signals.py: Guard against use in non-main thread
---
 buildstream/_signals.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/buildstream/_signals.py b/buildstream/_signals.py
index 9749e0d..06849c9 100644
--- a/buildstream/_signals.py
+++ b/buildstream/_signals.py
@@ -20,6 +20,7 @@
 import os
 import signal
 import sys
+import threading
 import traceback
 from contextlib import contextmanager, ExitStack
 from collections import deque
@@ -72,6 +73,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)