diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-08-23 15:33:31 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-09-10 10:44:53 +0000 |
commit | 1e1e7baeb7adf72ee1a206c58014d7b7eb753f1c (patch) | |
tree | 2e49c58565a6a652f5df9029ece08122a59093c5 /src | |
parent | e3567e107e3e3eea4b7a12b41e6f83c608c187cd (diff) | |
download | buildstream-1e1e7baeb7adf72ee1a206c58014d7b7eb753f1c.tar.gz |
scheduler.py: Notification for sched suspended status
Add a notification for SUSPENDED. Stored as a bool in Stream
which is flipped when the scheduler notifies that the event loop
has changed state.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/_scheduler/scheduler.py | 5 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py index 45f6a39d4..3c491b92d 100644 --- a/src/buildstream/_scheduler/scheduler.py +++ b/src/buildstream/_scheduler/scheduler.py @@ -58,6 +58,7 @@ class NotificationType(FastEnum): TERMINATED = "terminated" SUSPEND = "suspend" UNSUSPEND = "unsuspend" + SUSPENDED = "suspended" # Notification() @@ -399,6 +400,8 @@ class Scheduler(): if not self.suspended: 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() @@ -411,6 +414,8 @@ class Scheduler(): for job in self._active_jobs: job.resume() self.suspended = False + # Notify that we're unsuspended + self._notify(Notification(NotificationType.SUSPENDED)) self._starttime += (datetime.datetime.now() - self._suspendtime) self._notify(Notification(NotificationType.SCHED_START_TIME, time=self._starttime)) self._suspendtime = None diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 77d746ab7..e3d5eee89 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -93,6 +93,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 # init() # @@ -1087,7 +1088,7 @@ class Stream(): # @property def suspended(self): - return self._scheduler.suspended + return self._scheduler_suspended # terminated # @@ -1678,6 +1679,8 @@ 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") |