From f37621e5ec778876c8bcd2231cc53dcf47a70d75 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 31 Aug 2014 23:18:51 -0500 Subject: [PATCH] Use a deque for a FIFO instead of the python list LIFO. --- earwigbot/wiki/copyvios/workers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/earwigbot/wiki/copyvios/workers.py b/earwigbot/wiki/copyvios/workers.py index 61ec917..8e6bf93 100644 --- a/earwigbot/wiki/copyvios/workers.py +++ b/earwigbot/wiki/copyvios/workers.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +from collections import deque from gzip import GzipFile from logging import getLogger from math import log @@ -231,7 +232,7 @@ class _CopyvioWorker(object): self._logger.debug(logmsg.format(self._site)) self._queues.lock.acquire() try: - source = self._queue.pop() + source = self._queue.popleft() except IndexError: self._logger.debug("Queue is empty") del self._queues.sites[self._site] @@ -373,7 +374,7 @@ class CopyvioWorkspace(object): self._queues.sites[key].append(source) else: self._logger.debug(logmsg.format("new", key, url)) - self._queues.sites[key] = queue = [] + self._queues.sites[key] = queue = deque() queue.append(source) self._queues.unassigned.put((key, queue))