[apt-proxy-devel] r581 - people/halls/rework/apt_proxy

Chris Halls halls at costa.debian.org
Thu Sep 1 16:38:32 UTC 2005


Author: halls
Date: Thu Sep  1 16:38:31 2005
New Revision: 581

Modified:
   people/halls/rework/apt_proxy/fetchers.py
Log:
Add DownloadQueue - a class to manage a queue of files to download.
I want to have a per-backend queue, but a standalone class means we can
experiment with other queuing one per client connection, as with the
current apt-proxy.


Modified: people/halls/rework/apt_proxy/fetchers.py
==============================================================================
--- people/halls/rework/apt_proxy/fetchers.py	(original)
+++ people/halls/rework/apt_proxy/fetchers.py	Thu Sep  1 16:38:31 2005
@@ -927,3 +927,22 @@
         self.remove_request(request)
         if len(self.requests) == 0:
             Fetcher.apEnd(self)
+
+class DownloadQueue:
+    """
+    This class manages a list of files to download and schedules downloads
+    """
+    queuedFiles = []
+    activeFile = None
+
+    def addFile(self, cacheEntry):
+        """
+        Add a file to the queue and start downloading if necessary
+        """
+        self.queuedFiles.append(cacheEntry)
+        if self.activeFile is None:
+            self.startNextDownload()
+
+    def startNextDownload(self):
+        activeFile = queuedFiles[0]
+        queuedFiles = queuedFiles[1:]



More information about the apt-proxy-devel mailing list