def _wait(self):
if self.returncode is not None:
return self.returncode
- self.scheduler.schedule(self._reg_id)
+ if self.registered:
+ self.scheduler.schedule(self._reg_id)
self._set_returncode(os.waitpid(self.pid, 0))
return self.returncode
f.flush()
f.close()
self.registered = False
+ self._wait()
return self.registered
def _dummy_handler(self, fd, event):
for f in files.values():
f.close()
self.registered = False
+ self._wait()
return self.registered
class EbuildFetcher(SpawnProcess):
for f in files.values():
f.close()
self.registered = False
+ self._wait()
return self.registered
def _dummy_handler(self, fd, event):
for f in files.values():
f.close()
self.registered = False
+ self._wait()
return self.registered
def _set_returncode(self, wait_retval):
self._job_exit(merge.merge)
pkg = merge.merge.pkg
if merge.returncode != os.EX_OK:
- self._failed_pkgs.append((pkg, retval))
+ self._failed_pkgs.append((pkg, merge.returncode))
return
self._completed_tasks.add(pkg)
poll = self._poll.poll
max_jobs = self._max_jobs
- self._schedule_tasks()
+ state_change = 0
+
+ if self._schedule_tasks():
+ state_change += 1
while event_handlers:
jobs = self._jobs
for f, event in poll():
+ state_change += 1
handler, reg_id = event_handlers[f]
if not handler(f, event):
self._unregister(reg_id)
if jobs == self._jobs:
continue
- self._schedule_tasks()
+ if self._schedule_tasks():
+ state_change += 1
if not wait and self._jobs < max_jobs:
break
+ if not state_change and not event_handlers and self._jobs:
+ raise AssertionError("tight loop")
+
+ def _schedule_tasks(self):
+ state_change = 0
+ for x in self._task_queues.values():
+ if x.schedule():
+ state_change += 1
+ return bool(state_change)
+
def _task(self, pkg, background):
task = MergeListItem(args_set=self._args_set,
del self._poll_event_handler_ids[reg_id]
self._schedule_tasks()
- def _schedule_tasks(self):
- for x in self._task_queues.values():
- x.schedule()
-
def _schedule(self, wait_id):
"""
Schedule until wait_id is not longer registered