portage.writemsg_stdout("Regenerating cache entries...\n")
every_cp.sort(reverse=True)
try:
- while not self._terminated.is_set():
+ while not self._terminated_tasks:
yield every_cp.pop()
except IndexError:
pass
consumer = self._consumer
for cp in self._cp_iter:
- if self._terminated.is_set():
+ if self._terminated_tasks:
break
cp_set.add(cp)
portage.writemsg_stdout("Processing %s\n" % cp)
cpv_list = portdb.cp_list(cp)
for cpv in cpv_list:
- if self._terminated.is_set():
+ if self._terminated_tasks:
break
valid_pkgs.add(cpv)
ebuild_path, repo_path = portdb.findname2(cpv)
while self._jobs:
self._poll_loop()
- if self._terminated.is_set():
+ if self._terminated_tasks:
self.returncode = 1
return
@returns: True if there may be remaining tasks to schedule,
False otherwise.
"""
+ if self._terminated_tasks:
+ return False
+
while self._can_add_job():
- if self._terminated.is_set():
- return False
try:
metadata_process = next(self._process_iter)
except StopIteration:
self.returncode = 1
self._error_count += 1
self._valid_pkgs.discard(metadata_process.cpv)
- if not self._terminated.is_set():
+ if not self._terminated_tasks:
portage.writemsg("Error processing %s, continuing...\n" % \
(metadata_process.cpv,), noiselevel=-1)
"""
raise NotImplementedError()
+ def _schedule_tasks(self):
+ """
+ This is called from inside the _schedule() method, which
+ guarantees the following:
+
+ 1) It will not be called recursively.
+ 2) _terminate_tasks() will not be called while it is running.
+ 3) The state of the boolean _terminated_tasks variable will
+ not change while it is running.
+
+ Unless this method is used to perform user interface updates,
+ or something like that, the first thing it should do is check
+ the state of _terminated_tasks and if that is True then it
+ should return False immediately (since there's no need to
+ schedule anything after _terminate_tasks() has been called).
+ """
+ raise NotImplementedError()
+
def _schedule(self):
"""
Calls _schedule_tasks() and automatically returns early from
return self._jobs
def _can_add_job(self):
+ if self._terminated_tasks:
+ return False
+
max_jobs = self._max_jobs
max_load = self._max_load
@returns: True if there may be remaining tasks to schedule,
False otherwise.
"""
+ if self._terminated_tasks:
+ return False
+
while self._can_add_job():
n = self._max_jobs - self._running_job_count()
if n < 1:
build_dir=build_dir, build_log=build_log,
pkg=pkg,
returncode=merge.returncode))
- if not self._terminated.is_set():
+ if not self._terminated_tasks:
self._failed_pkg_msg(self._failed_pkgs[-1], "install", "to")
self._status_display.failed = len(self._failed_pkgs)
return
mtimedb.commit()
def _build_exit(self, build):
- if build.returncode == os.EX_OK and self._terminated.is_set():
+ if build.returncode == os.EX_OK and self._terminated_tasks:
# We've been interrupted, so we won't
# add this to the merge queue.
self.curval += 1
build_dir=build_dir, build_log=build_log,
pkg=build.pkg,
returncode=build.returncode))
- if not self._terminated.is_set():
+ if not self._terminated_tasks:
self._failed_pkg_msg(self._failed_pkgs[-1], "emerge", "for")
self._status_display.failed = len(self._failed_pkgs)
self._deallocate_config(build.settings)
self._poll_loop()
def _keep_scheduling(self):
- return bool(not self._terminated.is_set() and self._pkg_queue and \
+ return bool(not self._terminated_tasks and self._pkg_queue and \
not (self._failed_pkgs and not self._build_opts.fetchonly))
def _is_work_scheduled(self):