diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-03-16 21:50:36 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-03-18 12:48:53 -0700 |
commit | 379b1e85b516ca17f0f220ec8ac9b9997a2b8c22 (patch) | |
tree | ee8117606f5ca1a63d2fab3a1dd0f7bbd1e5b2bc /pym | |
parent | ef507665cb7b3fe697126f75e794025edf3f03eb (diff) | |
download | portage-379b1e85b516ca17f0f220ec8ac9b9997a2b8c22.tar.gz portage-379b1e85b516ca17f0f220ec8ac9b9997a2b8c22.tar.bz2 portage-379b1e85b516ca17f0f220ec8ac9b9997a2b8c22.zip |
Scheduler: tweak prefetcher cancellation logic
This should prevent "TypeError: an integer is required" raised from
waitpid when trying to cancel a prefetcher that never started.
Diffstat (limited to 'pym')
-rw-r--r-- | pym/_emerge/AbstractPollTask.py | 3 | ||||
-rw-r--r-- | pym/_emerge/Binpkg.py | 5 | ||||
-rw-r--r-- | pym/_emerge/EbuildBuild.py | 5 | ||||
-rw-r--r-- | pym/_emerge/Scheduler.py | 10 |
4 files changed, 16 insertions, 7 deletions
diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTask.py index 6cbf984b9..f7f3a9526 100644 --- a/pym/_emerge/AbstractPollTask.py +++ b/pym/_emerge/AbstractPollTask.py @@ -17,6 +17,9 @@ class AbstractPollTask(AsynchronousTask): _registered_events = PollConstants.POLLIN | PollConstants.POLLHUP | \ _exceptional_events + def isAlive(self): + return bool(self._registered) + def _read_buf(self, f, event): """ | POLLIN | RETURN diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py index b011b001f..00587451a 100644 --- a/pym/_emerge/Binpkg.py +++ b/pym/_emerge/Binpkg.py @@ -77,9 +77,8 @@ class Binpkg(CompositeTask): prefetcher = self.prefetcher if prefetcher is None: pass - elif not prefetcher.isAlive(): - prefetcher.cancel() - elif prefetcher.poll() is None: + elif prefetcher.isAlive() and \ + prefetcher.poll() is None: waiting_msg = ("Fetching '%s' " + \ "in the background. " + \ diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index f7381ca5c..98f5a2bf6 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -65,9 +65,8 @@ class EbuildBuild(CompositeTask): prefetcher = self.prefetcher if prefetcher is None: pass - elif not prefetcher.isAlive(): - prefetcher.cancel() - elif prefetcher.poll() is None: + elif prefetcher.isAlive() and \ + prefetcher.poll() is None: waiting_msg = "Fetching files " + \ "in the background. " + \ diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index b5b258d4a..5d190428f 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -1819,6 +1819,14 @@ class Scheduler(PollScheduler): "installed", pkg.root_config, installed=True, operation="uninstall") + prefetcher = self._prefetchers.pop(pkg, None) + if prefetcher is not None and not prefetcher.isAlive(): + try: + self._task_queues.fetch._task_queue.remove(prefetcher) + except ValueError: + pass + prefetcher = None + task = MergeListItem(args_set=self._args_set, background=self._background, binpkg_opts=self._binpkg_opts, build_opts=self._build_opts, @@ -1828,7 +1836,7 @@ class Scheduler(PollScheduler): find_blockers=self._find_blockers(pkg), logger=self._logger, mtimedb=self._mtimedb, pkg=pkg, pkg_count=self._pkg_count.copy(), pkg_to_replace=pkg_to_replace, - prefetcher=self._prefetchers.get(pkg), + prefetcher=prefetcher, scheduler=self._sched_iface, settings=self._allocate_config(pkg.root), statusMessage=self._status_msg, |