summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/_scheduler/scheduler.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 80bd9fb50..37a14c103 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -142,6 +142,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 +433,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()
#