Commits

Gustavo Picon committed 338b7ef

Added dynamic pool resizing.

  • Participants
  • Parent commits a84b70b
  • Tags 4.0.0beta-20140210

Comments (0)

Files changed (2)

File cheroot/workers/threadpool.py

 import threading
 import time
 
+from dynpool import DynamicPoolResizer
+
 
 class TrueyZero(object):
     """An object which equals and does math like the integer '0' but evals True
         """Number of worker threads which are idle. Read-only."""
         return len([t for t in self._threads if t.conn is None])
 
+    @property
+    def size(self):
+        return len(self._threads)
+
     def put(self, obj):
         self._queue.put(obj)
 
         worker.start()
         return worker
 
+    @staticmethod
     def _all(func, items):
         results = [func(item) for item in items]
         return functools.reduce(operator.and_, results, True)
-    _all = staticmethod(_all)
 
     def shrink(self, amount):
         """Kill off worker threads (not below self.min)."""
     @property
     def qsize(self):
         return self._queue.qsize()
+
+    def get_pool_resizer(self, minspare=1, maxspare=5, shrinkfreq=10,
+                         logger=None):
+        return DynamicPoolResizer(self, minspare, maxspare, shrinkfreq, logger)
         packages=packages,
         download_url=download_url,
         data_files=data_files,
+        install_requires=[
+            "dynpool>=1.0",
+        ],
     )