> Viktor Massalogin wrote:
>>
>> Is it possible to interrupt the server (paste.httpserver.serve) from WSGI
>> application? I tried to raise ServerExit, but ThreadPoolMixIn.handle_error()
>> does not stop the server.
>
> There's nothing very specific, I'm afraid, but probably KeyboardInterrupt
> would work.
>
> --
> Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org
>
I have tried:
<pre>
def application( environ, start_response ):
start_response('200 OK', [('Content-type', 'text/plain')])
yield "Hello, world"
#raise ServerExit
raise KeyboardInterrupt
</pre>
but it seems that
ThreadPoolMixIn.process_request_in_thread() in httpserver.py
handles the exception:
<pre>
def handle_error(self, request, client_address):
exc_class, exc, tb = sys.exc_info()
if exc_class is ServerExit:
# This is actually a request to stop the server
raise
return super(ThreadPoolMixIn, self).handle_error(request, client_address)
def process_request_in_thread(self, request, client_address):
"""
The worker thread should call back here to do the rest of the
request processing. Error handling normaller done in 'handle_request'
must be done here.
"""
try:
self.finish_request(request, client_address)
self.close_request(request)
except:
self.handle_error(request, client_address)
self.close_request(request)
</pre>
and the exception does not go to serve():
<pre>
...
try:
server.serve_forever()
except KeyboardInterrupt:
# allow CTRL+C to shutdown
pass
...
</pre>
_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users