summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2020-07-04 17:38:55 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2020-07-06 18:07:53 +0000
commitf701a80d19fb0ef87e339ef32ecdd098a936b813 (patch)
tree8c8bfeaf0e0d6820e72cdd6f62142193f935aa1f
parent46556cb03d4f5ddfd36cada6c92c5030e45f3447 (diff)
downloadbuildstream-f701a80d19fb0ef87e339ef32ecdd098a936b813.tar.gz
_stream.py: Stop using a 'SUSPENDED' event to know the state of the scheduler
We are calling the scheduler, and it returning correctly already tells us this.
-rw-r--r--src/buildstream/_scheduler/scheduler.py3
-rw-r--r--src/buildstream/_stream.py8
2 files changed, 4 insertions, 7 deletions
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 1a4ac2e2c..6e7eb4405 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -62,7 +62,6 @@ class NotificationType(FastEnum):
TERMINATED = "terminated"
SUSPEND = "suspend"
UNSUSPEND = "unsuspend"
- SUSPENDED = "suspended"
# Notification()
@@ -469,7 +468,6 @@ class Scheduler:
self._suspendtime = datetime.datetime.now()
self.suspended = True
# Notify that we're suspended
- self._notify(Notification(NotificationType.SUSPENDED))
for job in self._active_jobs:
job.suspend()
@@ -484,7 +482,6 @@ class Scheduler:
self.suspended = False
# Notify that we're unsuspended
self._state.offset_start_time(datetime.datetime.now() - self._suspendtime)
- self._notify(Notification(NotificationType.SUSPENDED))
self._suspendtime = None
# _interrupt_event():
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 81c8a88ef..707d8c086 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -102,7 +102,7 @@ class Stream:
self._notifier = self._scheduler._stream_notification_handler # Assign the schedulers notification handler
self._scheduler_running = False
self._scheduler_terminated = False
- self._scheduler_suspended = False
+ self._suspended = False
# init()
#
@@ -1070,7 +1070,7 @@ class Stream:
#
@property
def suspended(self):
- return self._scheduler_suspended
+ return self._suspended
# terminated
#
@@ -1107,7 +1107,9 @@ class Stream:
# Send the notification to suspend jobs
notification = Notification(NotificationType.SUSPEND)
self._notify(notification)
+ self._suspended = True
yield
+ self._suspended = False
# Unsuspend jobs on context exit
notification = Notification(NotificationType.UNSUSPEND)
self._notify(notification)
@@ -1655,8 +1657,6 @@ class Stream:
self._scheduler_running = not self._scheduler_running
elif notification.notification_type == NotificationType.TERMINATED:
self._scheduler_terminated = True
- elif notification.notification_type == NotificationType.SUSPENDED:
- self._scheduler_suspended = not self._scheduler_suspended
else:
raise StreamError("Unrecognised notification type received: {}".format(notification.notification_type))