Scheduler: tweak _add_prefetchers
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2012 01:58:28 +0000 (17:58 -0800)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2012 01:58:28 +0000 (17:58 -0800)
Since commit 4620d6aba1c5c10344e311585516ee43819b703c, the first
prefetcher is started as soon as it's added to the task queue.

pym/_emerge/Scheduler.py

index d3f77611d07b2d234b423d393402daa1fdaccdfb..6502f71c5af85b2e15d0772eb2152f76d3a70fd2 100644 (file)
@@ -733,15 +733,13 @@ class Scheduler(PollScheduler):
                                        continue
                                prefetcher = self._create_prefetcher(pkg)
                                if prefetcher is not None:
-                                       self._task_queues.fetch.add(prefetcher)
+                                       # This will start the first prefetcher immediately, so that
+                                       # self._task() won't discard it. This avoids a case where
+                                       # the first prefetcher is discarded, causing the second
+                                       # prefetcher to occupy the fetch queue before the first
+                                       # fetcher has an opportunity to execute.
                                        prefetchers[pkg] = prefetcher
-
-                       # Start the first prefetcher immediately so that self._task()
-                       # won't discard it. This avoids a case where the first
-                       # prefetcher is discarded, causing the second prefetcher to
-                       # occupy the fetch queue before the first fetcher has an
-                       # opportunity to execute.
-                       self._task_queues.fetch.schedule()
+                                       self._task_queues.fetch.add(prefetcher)
 
        def _create_prefetcher(self, pkg):
                """