summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-10-29 16:03:46 +0000
committerTom Pollard <tom.pollard@codethink.co.uk>2019-10-29 16:03:46 +0000
commitaae4bbc4342dc4d30e2081279c26e34a6150db30 (patch)
tree6634986a8d0c38b9cba6bfdfeff18e6c943edfe8
parentc75339041484e1334b6f56a66aa442667a898036 (diff)
downloadbuildstream-tpollard/buildsubtemp.tar.gz
-rw-r--r--src/buildstream/_frontend/app.py8
-rw-r--r--src/buildstream/_scheduler/scheduler.py5
-rw-r--r--src/buildstream/_stream.py3
3 files changed, 13 insertions, 3 deletions
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py
index e146de9e5..d8ec3e739 100644
--- a/src/buildstream/_frontend/app.py
+++ b/src/buildstream/_frontend/app.py
@@ -518,14 +518,16 @@ class App():
try:
choice = click.prompt("Choice:",
- value_proc=_prefix_choice_value_proc(['continue', 'quit', 'terminate']),
+ value_proc=_prefix_choice_value_proc(['continue', 'quit', 'terminate', 'e']),
default='continue', err=True)
except click.Abort:
# Ensure a newline after automatically printed '^C'
click.echo("", err=True)
choice = 'terminate'
-
- if choice == 'terminate':
+ if choice == 'e':
+ from traceback import print_stack
+ print_stack(file=sys.stderr)
+ elif choice == 'terminate':
click.echo("\nTerminating all jobs at user request\n", err=True)
self.stream.terminate()
else:
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 3640d7b2d..2fe653267 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -534,6 +534,7 @@ class Scheduler():
if not self._notify_front_queue:
# Not running in a subprocess, scheduler process to handle keyboard interrupt
+ print("Scheduler called an interrupt")
notification = Notification(NotificationType.INTERRUPT)
self._notify_front(notification)
@@ -566,15 +567,19 @@ class Scheduler():
# Connects our signal handler event callbacks to the mainloop
#
def _connect_signals(self):
+ print("sched is connecting {}".format(os.getpid()))
self.loop.add_signal_handler(signal.SIGINT, self._interrupt_event)
self.loop.add_signal_handler(signal.SIGTERM, self._terminate_event)
self.loop.add_signal_handler(signal.SIGTSTP, self._suspend_event)
def _disconnect_signals(self):
+ print("sched is disconnecting {}".format(os.getpid()))
self.loop.remove_signal_handler(signal.SIGINT)
self.loop.remove_signal_handler(signal.SIGTSTP)
self.loop.remove_signal_handler(signal.SIGTERM)
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
+
def _terminate_jobs_real(self):
# 20 seconds is a long time, it can take a while and sometimes
# we still fail, need to look deeper into this again.
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 21c54105a..b5d2cd2ad 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -1860,6 +1860,7 @@ class Stream():
def _connect_signals(self):
if self.loop:
+ print("stream is connecting {}".format(os.getpid()))
self.loop.add_signal_handler(signal.SIGINT, self._interrupt_callback)
self.loop.add_signal_handler(signal.SIGTERM,
lambda: self._notify_back(Notification(NotificationType.TERMINATE)))
@@ -1868,9 +1869,11 @@ class Stream():
def _disconnect_signals(self):
if self.loop:
+ print("stream is disconnecting {}".format(os.getpid()))
self.loop.remove_signal_handler(signal.SIGINT)
self.loop.remove_signal_handler(signal.SIGTSTP)
self.loop.remove_signal_handler(signal.SIGTERM)
+ #signal.signal(signal.SIGINT, signal.SIG_IGN)
def __getstate__(self):
# The only use-cases for pickling in BuildStream at the time of writing