From 0b565f39752362a5a2e936fb8bfcb3b4d3d95c67 Mon Sep 17 00:00:00 2001 From: John Schember Date: Mon, 28 Feb 2011 20:14:39 -0500 Subject: [PATCH] Randomize the order in which plugins are added to the search queue. This way plugins with a lower letter do not have an unfair advantage. --- src/calibre/gui2/store/search.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/store/search.py b/src/calibre/gui2/store/search.py index 0d0c10a3cb..d77cf23bf8 100644 --- a/src/calibre/gui2/store/search.py +++ b/src/calibre/gui2/store/search.py @@ -7,7 +7,8 @@ __docformat__ = 'restructuredtext en' import re import time from contextlib import closing -from threading import Event, Thread +from random import shuffle +from threading import Thread from Queue import Queue from PyQt4.Qt import Qt, QAbstractItemModel, QDialog, QTimer, QVariant, \ @@ -87,7 +88,11 @@ class SearchDialog(QDialog, Ui_Dialog): if not query.strip(): return - for n in self.store_plugins: + store_names = self.store_plugins.keys() + if not store_names: + return + shuffle(store_names) + for n in store_names: if getattr(self, 'store_check_' + n).isChecked(): self.search_pool.add_task(query, n, self.store_plugins[n], TIMEOUT) if self.search_pool.has_tasks():