Commits

Jason R. Coombs committed e50561f

Updated _all_ready to be a more generic _all method, more similar to the all keyword in Python 2.5+.

Comments (0)

Files changed (1)

cherrypy/wsgiserver/wsgiserver2.py

         n_new = min(amount, budget)
 
         workers = [self._spawn_worker() for i in range(n_new)]
-        while not self._all_ready(workers):
+        while not self._all(operator.attrgetter('ready'), workers):
             time.sleep(.1)
         self._threads.extend(workers)
 
         worker.start()
         return worker
 
-    def _all_ready(workers):
-        ready_states = [worker.ready for worker in workers]
-        return reduce(operator.and_, ready_states, True)
-    _all_ready = staticmethod(_all_ready)
+    def _all(func, items):
+        results = [func(item) for item in items]
+        return reduce(operator.and_, results, True)
+    _all = staticmethod(_all)
 
     def shrink(self, amount):
         """Kill off worker threads (not below self.min)."""