Exiting threads silently
Michael Bauer
Mike_ba at web.de
Tue Feb 12 06:31:49 EST 2002
More information about the Python-list mailing list
Tue Feb 12 06:31:49 EST 2002
- Previous message (by thread): Exiting threads silently
- Next message (by thread): Exiting threads silently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, i have a small problem when exiting threads. According to the docs, a silent exit should be possible without an exception. from <http://www.python.org/doc/2.2/lib/module-thread.html>: "exit() Raise the SystemExit exception. When not caught, this will cause the thread to exit silently." Here is the relevant code (This is part of a proxy module) ---------------------------------------- def error(self, code, body): """Answer Client with an error page XXX Really not very nice page... """ import BaseHTTPServer response = BaseHTTPServer.BaseHTTPRequestHandler.responses[code][0] try: self.wfile.write("HTTP/1.0 %s %s\r\n" % (code, response)) self.wfile.write("Server: iOwl.net ProxyServer\r\n") self.wfile.write("Content-type: text/html\r\n") self.wfile.write("\r\n") self.wfile.write('<html><head>\n<title>%d %s</title>\n</head>\n' '<body>\n%s\n</body>\n</html>' % (code, response, body)) self.wfile.flush() self.wfile.close() self.rfile.close() except IOError: # probably user aborted browser so we dont have a socket left # to write to pass # Exit thread thread.exit() ---------------------------------------- What happens is the error page gets displayed correctly in the browser, but therad.exit() dumps following exception to the console: ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 40400) Traceback (most recent call last): File "/usr/lib/python2.2/SocketServer.py", line 458, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.2/SocketServer.py", line 253, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.2/SocketServer.py", line 514, in __init__ self.handle() File "/home/fake/devel/iowl/pProxy/cProxyHandler.py", line 170, in handle server, client = self.Connect(host, port) File "/home/fake/devel/iowl/pProxy/cProxyHandler.py", line 346, in Connect self.error(200, 'Error connecting to "%s" (%s)' % (host, err)) File "/home/fake/devel/iowl/pProxy/cProxyHandler.py", line 504, in error thread.exit() SystemExit ---------------------------------------- Anybody has an idea how i can exit silently? thanks, Mike (Running on linux from scratch, kernel 2.4.17 with Python 2.2)
- Previous message (by thread): Exiting threads silently
- Next message (by thread): Exiting threads silently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list