r231 - branches/rewrite/src

Otavio Salvador partial-mirror-devel@lists.alioth.debian.org
Tue, 21 Sep 2004 16:48:54 -0600


Author: otavio
Date: Tue Sep 21 16:48:53 2004
New Revision: 231

Modified:
   branches/rewrite/src/Download.py
Log:
Use inherits to implements the thread

Modified: branches/rewrite/src/Download.py
==============================================================================
--- branches/rewrite/src/Download.py	(original)
+++ branches/rewrite/src/Download.py	Tue Sep 21 16:48:53 2004
@@ -37,7 +37,7 @@
     print "Total to upload", upload_t
     print "Total uploaded", upload_d
 
-class DownloadFetcher:
+class DownloadFetcher(threading.Thread):
     def __init__(self, max_connections = 2):
         """ Make the needed objects to handle the connections."""
         self.__objs = pycurl.CurlMulti()
@@ -55,9 +55,11 @@
 #            c.setopt(pycurl.VERBOSE, 1)
             self.__handles.append(c)
 
-        threading.Thread(target=self.thread).start()
+        threading.Thread.__init__(self)
+        self.setName('DownloadFetcher Thread')
+        self.start()
 
-    def thread(self):
+    def run(self):
         while 1:
             while Download.queue and self.__handles:
                 url, filename = Download.queue.get()
@@ -94,6 +96,7 @@
                 if num_q == 0:
                     break
 
+            print "Looping externo."
             # Currently no more I/O is pending, could do something in the meantime
             # (display a progress bar, etc.).
             # We just use select() to wait until some more data is available.