diff options
Diffstat (limited to 'src/buildstream/_scheduler')
-rw-r--r-- | src/buildstream/_scheduler/scheduler.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py index 80bd9fb50..d9a0984da 100644 --- a/src/buildstream/_scheduler/scheduler.py +++ b/src/buildstream/_scheduler/scheduler.py @@ -1,5 +1,6 @@ # # Copyright (C) 2016 Codethink Limited +# Copyright (C) 2019 Bloomberg Finance LP # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -142,6 +143,8 @@ class Scheduler: self._state = state self._casd_process = None # handle to the casd process for monitoring purpose + self._sched_handle = None # Whether a scheduling job is already scheduled or not + # Bidirectional queue to send notifications back to the Scheduler's owner self._notification_queue = notification_queue self._notifier = notifier @@ -431,20 +434,26 @@ class Scheduler: # going back to sleep. # def _sched(self): + def real_schedule(): + if not self.terminated: + + # + # Run as many jobs as the queues can handle for the + # available resources + # + self._sched_queue_jobs() - if not self.terminated: + # Reset the scheduling hand + self._sched_handle = None # - # Run as many jobs as the queues can handle for the - # available resources + # If nothing is ticking then bail out # - self._sched_queue_jobs() + if not self._active_jobs: + self.loop.stop() - # - # If nothing is ticking then bail out - # - if not self._active_jobs: - self.loop.stop() + if self._sched_handle is None: + self._sched_handle = self.loop.call_soon(real_schedule) # _suspend_jobs() # |