Commits

Robert Brewer  committed b75ece4

Fix for #956 (wsgiserver's ThreadPool stop() method can take longer than timeout arg to complete).

  • Participants
  • Parent commits cacec1f

Comments (0)

Files changed (1)

File cherrypy/wsgiserver/__init__.py

         
         # Don't join currentThread (when stop is called inside a request).
         current = threading.currentThread()
+        if timeout and timeout >= 0:
+            endtime = time.time() + timeout
         while self._threads:
             worker = self._threads.pop()
             if worker is not current and worker.isAlive():
                     if timeout is None or timeout < 0:
                         worker.join()
                     else:
-                        worker.join(timeout)
+                        remaining_time = endtime - time.time()
+                        if remaining_time > 0:
+                            worker.join(remaining_time)
                         if worker.isAlive():
                             # We exhausted the timeout.
                             # Forcibly shut down the socket.