From 11beef0bc900391315860f9ac07d065382008519 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 6 Jun 2017 08:59:12 -0700 Subject: Fix error on httpserver shutdown If a worker thread takes longer than 0.5s to shut down, we try to kill it. However, if it manages to stop between the 0.5s timeout and the call to kill_worker, kill_worker will raise an exception and abort shutdown. Handle that case with an exception handler. --- paste/httpserver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'paste/httpserver.py') diff --git a/paste/httpserver.py b/paste/httpserver.py index 035d818..11489b0 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -734,7 +734,11 @@ class ThreadPool(object): raise RuntimeError( "Cannot kill worker; killthread/ctypes not available") thread_obj = threading._active.get(thread_id) - killthread.async_raise(thread_id, SystemExit) + try: + killthread.async_raise(thread_id, SystemExit) + except ValueError: + # invalid thread id -- the thread has died in the mean time + pass try: del self.worker_tracker[thread_id] except KeyError: -- cgit v1.2.1