From 44dd378ece4917e02c080c275f2ce85a2a85126b Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Fri, 15 May 2020 22:35:52 +0900 Subject: _scheduler/scheduler.py: Reset the schedule handler at the beginning of real_schedule() In case queuing jobs results in jobs completing, we need to reset the schedule handler at the beginning of the function and not after queueing the jobs. This fixes the failure to exit the main loop in #1312 --- src/buildstream/_scheduler/scheduler.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py index 15ae85e04..cf4581f00 100644 --- a/src/buildstream/_scheduler/scheduler.py +++ b/src/buildstream/_scheduler/scheduler.py @@ -459,6 +459,21 @@ class Scheduler: # def _sched(self): def real_schedule(): + + # Reset the scheduling handle before queuing any jobs. + # + # We do this right away because starting jobs can result + # in their being terminated and completed during the body + # of this function, and we want to be sure that we get + # called again in this case. + # + # This can happen if jobs are explicitly killed as a result, + # which might happen as a side effect of a crash in an + # abstracted frontend implementation handling notifications + # about jobs starting. + # + self._sched_handle = None + if not self.terminated: # @@ -467,9 +482,6 @@ class Scheduler: # self._sched_queue_jobs() - # Reset the scheduling hand - self._sched_handle = None - # # If nothing is ticking then bail out # -- cgit v1.2.1