示例#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)
示例#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)
示例#3
0
 def preloop(self):
     self.downloads = []
     mi = multi_iter(self.downloads, terminate=False)
     self.lc = ThreadedLoopingCall(mi.next)
     self.lc.start()
示例#4
0
 def preloop(self):
     self.downloads = []
     mi = multi_iter(self.downloads, terminate=False)
     self.lc = ThreadedLoopingCall(mi.next)
     self.lc.start()