summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2017-06-06 08:59:12 -0700
committerJames E. Blair <jeblair@redhat.com>2017-06-06 08:59:12 -0700
commit11beef0bc900391315860f9ac07d065382008519 (patch)
tree978bf10572b62a4a97f37d7614a89848f9f90533
parentbf91535c2481d5526fae3f6acbb5de6e46f5846c (diff)
downloadpaste-11beef0bc900391315860f9ac07d065382008519.tar.gz
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.
-rwxr-xr-xpaste/httpserver.py6
1 files changed, 5 insertions, 1 deletions
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: