Scheduler: fix parallel-fetch order with --jobs=1
authorZac Medico <zmedico@gentoo.org>
Wed, 3 Aug 2011 05:10:47 +0000 (22:10 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 3 Aug 2011 05:10:47 +0000 (22:10 -0700)
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.

pym/_emerge/Scheduler.py

index d13e62266abe5ee3cf39b008e366b04cf37f9cca..6412d821db53bbf943ad047e0808b3a206f92cb2 100644 (file)
@@ -752,6 +752,13 @@ class Scheduler(PollScheduler):
                                        self._task_queues.fetch.add(prefetcher)
                                        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()
+
        def _create_prefetcher(self, pkg):
                """
                @return: a prefetcher, or None if not applicable