目前我正在使用一个用 python 构建的应用程序。当我在个人电脑上运行它时,它没有问题。
但是,当我将其移至生产服务器时。它一直向我显示如下附加的错误:。
我做了一些研究,我得到了最终用户浏览器在服务器仍在忙于发送数据时停止连接的原因。
我想知道为什么会发生这种情况,阻止它在生产服务器上正常运行的根本原因是什么,而它在我的个人计算机上运行。任何建议表示赞赏
Exception happened during processing of request from ('127.0.0.1', 34226)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 284, in
_handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 641, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 694, in finish
self.wfile.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
原文由 SƲmmēr Aƥ 发布,翻译遵循 CC BY-SA 4.0 许可协议
您的服务器进程已收到
SIGPIPE
写入套接字。当您写入在另一端(客户端)完全关闭的套接字时,通常会发生这种情况。当客户端程序没有等到接收到来自服务器的所有数据并简单地关闭套接字(使用close
函数)时,可能会发生这种情况。在 C 程序中,您通常会尝试设置为忽略
SIGPIPE
信号或为其设置虚拟信号处理程序。在这种情况下,写入关闭的套接字时将返回一个简单的错误。在您的情况下,python 似乎会抛出一个异常,该异常可以作为客户端过早断开连接来处理。