Commits

Jason R. Coombs committed cdcfe82

Now spawn all workers before adding them to the thread pool.

  • Participants
  • Parent commits e759049
  • Branches cherrypy-3.2.x

Comments (0)

Files changed (2)

File cherrypy/wsgiserver/wsgiserver2.py

 
         n_new = min(amount, budget)
 
-        for i in range(n_new):
-            worker = WorkerThread(self.server)
-            worker.setName("CP Server " + worker.getName())
-            self._threads.append(worker)
-            worker.start()
+        workers = [self._spawn_worker() for i in range(n_new)]
+        self._threads.extend(workers)
+
+    def _spawn_worker(self):
+        worker = WorkerThread(self.server)
+        worker.setName("CP Server " + worker.getName())
+        worker.start()
+        return worker
 
     def shrink(self, amount):
         """Kill off worker threads (not below self.min)."""

File cherrypy/wsgiserver/wsgiserver3.py

 
         n_new = min(amount, budget)
 
-        for i in range(n_new):
-            worker = WorkerThread(self.server)
-            worker.setName("CP Server " + worker.getName())
-            self._threads.append(worker)
-            worker.start()
+        workers = [self._spawn_worker() for i in range(n_new)]
+        self._threads.extend(workers)
+
+    def _spawn_worker(self):
+        worker = WorkerThread(self.server)
+        worker.setName("CP Server " + worker.getName())
+        worker.start()
+        return worker
 
     def shrink(self, amount):
         """Kill off worker threads (not below self.min)."""