return task._start(self) self.log.debug("found client %s", task.url) except Queue.Empty: break if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG, format='%(name)s: %(message)s', ) manager = TaskManager(lambda s: None) downloader = BackgroundHttpDownloader() manager.start_dispatcher(downloader) manager.add_task(DownloadTask('http://www.python.org/', "python.html", overwrite=True)) manager.add_task(DownloadTask('http://www.doughellmann.com/PyMOTW/contents.html',"pymotw.html")) manager.add_task(DownloadTask('http://docs.python.org/release/2.6.8/_static/py.png', "py.png")) manager.add_task(DownloadTask('http://docs.python.org/release/2.6.8/_static/py.png', "py2.png")) manager.add_task(DownloadTask('http://docs.python.org/release/2.6.8/_static/py.png', "py3.png")) manager.add_task(DownloadTask('http://image.tmdb.org/t/p/w342/vpk4hLyiuI2SqCss0T3jeoYcL8E.jpg', "test.jpg")) for i in range(10): time.sleep(1) tasks = manager.get_finished() for task in tasks: print 'FINISHED:', task.size, 'bytes for', task.path, 'from', task.url if i == 5: manager.add_task(DownloadTask('http://www.python.org/images/python-logo.gif', "bigpy.gif")) manager.shutdown()