portdb=portdb, repo_path=repo_path,
settings=portdb.doebuild_settings)
+ def _keep_scheduling(self):
+ return self._remaining_tasks and not self._terminated_tasks
+
def run(self):
portdb = self._portdb
from portage.cache.cache_errors import CacheError
dead_nodes = {}
- self._schedule()
- while self._remaining_tasks and not self._terminated_tasks:
- self.sched_iface.iteration()
-
- while self._jobs:
- self.sched_iface.iteration()
+ self._main_loop()
if self._terminated_tasks:
self.returncode = 1
finally:
self._scheduling = False
+ def _main_loop(self):
+ # Populate initial event sources. We only need to do
+ # this once here, since it can be called during the
+ # loop from within event handlers.
+ self._schedule()
+
+ # Loop while there are jobs to be scheduled.
+ while self._keep_scheduling():
+ self.sched_iface.iteration()
+
+ # Clean shutdown of previously scheduled jobs. In the
+ # case of termination, this allows for basic cleanup
+ # such as flushing of buffered output to logs.
+ while self._is_work_scheduled():
+ self.sched_iface.iteration()
+
+ def _keep_scheduling(self):
+ return False
+
+ def _is_work_scheduled(self):
+ return bool(self._running_job_count())
+
def _running_job_count(self):
return self._jobs
timeout, timeout_callback)
try:
-
- while not (timeout_callback is not None and
- timeout_callback.timed_out) and self._schedule():
- self.sched_iface.iteration()
-
- while not (timeout_callback is not None and
- timeout_callback.timed_out) and self._running_job_count():
- self.sched_iface.iteration()
-
+ self._main_loop()
except StopIteration:
pass
finally:
def _merge(self):
+ if self._opts_no_background.intersection(self.myopts):
+ self._set_max_jobs(1)
+
self._add_prefetchers()
self._add_packages()
failed_pkgs = self._failed_pkgs
def _deallocate_config(self, settings):
self._config_pool[settings['EROOT']].append(settings)
- def _main_loop(self):
-
- if self._opts_no_background.intersection(self.myopts):
- self._set_max_jobs(1)
-
- self._schedule()
- while self._keep_scheduling():
- self.sched_iface.iteration()
-
- while self._is_work_scheduled():
- self.sched_iface.iteration()
-
def _keep_scheduling(self):
return bool(not self._terminated_tasks and self._pkg_queue and \
not (self._failed_pkgs and not self._build_opts.fetchonly))