Commits

Benjamin Wohlwend  committed 356f2d7

Create worker threads only when needed and dismiss them after they finished their work. This gets rid of ugly error messages during application shutdown.

  • Participants
  • Parent commits 0d879df

Comments (0)

Files changed (1)

File src/undercover/fetchers/__init__.py

     Gets a list of cover URLs from every registered fetcher and starts
     downloading them 
     """
-    __pool = threadpool.ThreadPool(num_workers=5)
+    __pool = threadpool.ThreadPool(0)
     registry = set()
     
     def __init__(self, queries, progress_slot=None, image_slot=None, finished_slot=None, status_slot=None):
                                    QtCore.Qt.QueuedConnection)
     
     def run(self):
+        self.__pool.createWorkers(5, 0.5)
         urls_count = 0
         for query in self.__queries:
             for fetcher in Downloader.registry:
         if urls_count == 0:
             self.emit(QtCore.SIGNAL('showMessage(QString, int)'), self.tr('No covers have been found'), 5000)
         self.__pool.wait()
+        self.__pool.dismissWorkers(5, True)
         self.emit(QtCore.SIGNAL('finished()'))