处理请求时发生异常

时间:2015-01-20 11:08:20

标签: python

Exception happened during processing of request from ('192.168.227.112', 49343)
Traceback (most recent call last):
    File "/usr/lib/python2.6/SocketServer.py", line 283, in _handle_request_noblock
        self.process_request(request, client_address)
    File "/usr/lib/python2.6/SocketServer.py", line 309, in process_request
        self.finish_request(request, client_address)
    File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
        self.RequestHandlerClass(request, client_address, self)
    File "/usr/lib/python2.6/SocketServer.py", line 617, in __init__
        self.handle()
    File "/usr/lib/python2.6/wsgiref/simple_server.py", line 130, in handle
        self.raw_requestline = self.rfile.readline()
    File "/usr/lib/python2.6/socket.py", line 444, in readline
        data = self._sock.recv(self._rbufsize)
KeyboardInterrupt

某处的代码块。然后我必须按 Ctrl-c 来杀死阻塞点,以便程序可以继续运行。如果阻止发生,程序变得非常缓慢。任何人都可以有很好的建议来解决这个问题吗?

1 个答案:

答案 0 :(得分:-2)

这个怎么样? 发生错误时可以放excepion

例如脚本:

try:
   ...first_conditional

except KeyboardInterrupt:
   ...your_optional_conditional

检查此文档:https://docs.python.org/2/library/exceptions.html#exceptions.KeyboardInterrupt