Exemplo n.º 1
0
class QuasiAsynchronousDownloader(Downloader):
    def preloop(self):
        self.downloads = []
        mi = multi_iter(self.downloads, terminate=False)
        self.lc = ThreadedLoopingCall(mi.next)
        self.lc.start()
    def postloop(self):
        self.lc.stop()
        Downloader.postloop(self)
    def do_download(self, arg):
        self.downloads.append(self.download(arg))
    def download(self, fname):
        self.out.write("BEGIN %s" % fname)
        for line in file(fname):
            time.sleep(.1)
            self.out.write(".")
            yield None
        self.out.write(" END %s\n" % fname)
Exemplo n.º 2
0
class QuasiAsynchronousDownloader(Downloader):
    def preloop(self):
        self.downloads = []
        mi = multi_iter(self.downloads, terminate=False)
        self.lc = ThreadedLoopingCall(mi.next)
        self.lc.start()

    def postloop(self):
        self.lc.stop()
        Downloader.postloop(self)

    def do_download(self, arg):
        self.downloads.append(self.download(arg))

    def download(self, fname):
        self.out.write("BEGIN %s" % fname)
        for line in file(fname):
            time.sleep(.1)
            self.out.write(".")
            yield None
        self.out.write(" END %s\n" % fname)
Exemplo n.º 3
0
 def preloop(self):
     self.downloads = []
     mi = multi_iter(self.downloads, terminate=False)
     self.lc = ThreadedLoopingCall(mi.next)
     self.lc.start()
Exemplo n.º 4
0
 def preloop(self):
     self.downloads = []
     mi = multi_iter(self.downloads, terminate=False)
     self.lc = ThreadedLoopingCall(mi.next)
     self.lc.start()