1. cherrypy
  2. cheroot


Gustavo Picon  committed 338b7ef

Added dynamic pool resizing.

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

Comments (0)

Files changed (2)

File cheroot/workers/threadpool.py

View file
 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):
         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)."""
     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)

File setup.py

View file
+        install_requires=[
+            "dynpool>=1.0",
+        ],