diff options
author | ianb <devnull@localhost> | 2007-02-21 20:25:07 +0000 |
---|---|---|
committer | ianb <devnull@localhost> | 2007-02-21 20:25:07 +0000 |
commit | 5fef8c60de388f61797641f70649a48809747cd9 (patch) | |
tree | a74d93da74849657bdbabbbe314265017025a834 /paste/httpserver.py | |
parent | bf8a620b33fb98d11508495f97a485c1fbcd73d8 (diff) | |
download | paste-5fef8c60de388f61797641f70649a48809747cd9.tar.gz |
Call exc_clear after worker threads are done, to remove any lingering frames from past exceptions
Diffstat (limited to 'paste/httpserver.py')
-rwxr-xr-x | paste/httpserver.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/paste/httpserver.py b/paste/httpserver.py index a2eb634..76cbe3a 100755 --- a/paste/httpserver.py +++ b/paste/httpserver.py @@ -18,6 +18,7 @@ if pyOpenSSL is installed, it also provides SSL capabilities. # till this is completed. import atexit +import traceback import socket, sys, threading, urlparse, Queue, urllib import posixpath import time @@ -520,12 +521,22 @@ class ThreadPool(object): else: self.worker_tracker[thread.get_ident()] = [time.time(), None] try: - runnable() + try: + runnable() + except: + # We are later going to call sys.exc_clear(), + # removing all remnants of any exception, so + # we should log it now. But ideally no + # exception should reach this level + print >> sys.stderr, ( + 'Unexpected exception in worker %r' % runnable) + traceback.print_exc() finally: try: del self.worker_tracker[thread.get_ident()] except KeyError: pass + sys.exc_clear() def shutdown(self): """ |