summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Pollard <tom.pollard@codethink.co.uk>2019-08-22 17:50:30 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-10 10:44:53 +0000
commit7c2014a0cfc95e85460b92a6497bb88fb5a34927 (patch)
tree4cadd30420318dd8dd2dfad41cff0ca2eaacc221
parent0c583026c8a3ae94e905f57d43beda88808ea990 (diff)
downloadbuildstream-7c2014a0cfc95e85460b92a6497bb88fb5a34927.tar.gz
scheduler.py: Notification for sched terminated status
Add a notification for TERMINATED, which is notified as True in Stream when the scheduler terminates the event loop via user interactivity or SIG handling.
-rw-r--r--src/buildstream/_scheduler/scheduler.py5
-rw-r--r--src/buildstream/_stream.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 816da40e0..082580bcf 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -56,6 +56,7 @@ class NotificationType(FastEnum):
QUIT = "quit"
SCHED_START_TIME = "sched_start_time"
RUNNING = "running"
+ TERMINATED = "terminated"
# Notification()
@@ -229,6 +230,10 @@ class Scheduler():
# attribute to decide whether or not to print status info
# etc and the following code block will trigger some callbacks.
self.terminated = True
+
+ # Notify the frontend that we're terminated as it might be
+ # from an interactive prompt callback or SIGTERM
+ self._notify(Notification(NotificationType.TERMINATED))
self.loop.call_soon(self._terminate_jobs_real)
# Block this until we're finished terminating jobs,
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index e346109fe..d3e1d362c 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -92,6 +92,7 @@ class Stream():
self._interrupt_callback = interrupt_callback
self._notifier = self._scheduler._stream_notification_handler # Assign the schedulers notification handler
self._scheduler_running = False
+ self._scheduler_terminated = False
# init()
#
@@ -1094,7 +1095,7 @@ class Stream():
#
@property
def terminated(self):
- return self._scheduler.terminated
+ return self._scheduler_terminated
# elapsed_time
#
@@ -1670,6 +1671,8 @@ class Stream():
self._starttime = notification.time
elif notification.notification_type == NotificationType.RUNNING:
self._scheduler_running = not self._scheduler_running
+ elif notification.notification_type == NotificationType.TERMINATED:
+ self._scheduler_terminated = True
else:
raise StreamError("Unrecognised notification type received")