python的BaseHTTPRequestHandler的bug


用python写的服务报异常了。

Traceback (most recent call last):
  File "/usr/local/python-2.7.4/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/local/python-2.7.4/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/local/python-2.7.4/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/python-2.7.4/lib/python2.7/SocketServer.py", line 651, in __init__
    self.finish()
  File "/usr/local/python-2.7.4/lib/python2.7/SocketServer.py", line 710, in finish
    self.wfile.close()
  File "/usr/local/python-2.7.4/lib/python2.7/socket.py", line 279, in close
    self.flush()
  File "/usr/local/python-2.7.4/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe

大概就是python对于一些异常的socket情况没有处理好才导致的bug。


关于这个异常的bug report:

http://bugs.python.org/issue14574

相关讨论和解决方案:
http://stackoverflow.com/questions/6063416/python-basehttpserver-how-do-i-catch-trap-broken-pipe-errors


本来是考虑到有一个需求,需要起一个server,对速度没有什么要求,就随便用python简单写了一个。

没想到这么不靠谱。


最后还是用c++写了。。




你可能感兴趣的:(python的BaseHTTPRequestHandler的bug)