如何防止errno 32管道破裂? [英] How to prevent errno 32 broken pipe?

查看:100
本文介绍了如何防止errno 32管道破裂?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在使用内置的python应用。当我在个人计算机上运行它时,它可以正常工作。

Currently I am using an app built in python. When I run it in personal computer, it works without problems.

但是,当我将其移入生产服务器时。它不断向我显示以下错误:

However, when I move it into a production server. It keeps showing me the error attached as below:.

我进行了一些研究,我了解到最终用户浏览器在服务器仍在忙于发送数据时会停止连接的原因。

I've done some research and I got the reason that the end user browser stops the connection while the server is still busy sending data.

我想知道为什么会发生这种情况,以及导致它在我的个人计算机上运行时阻止它在生产服务器中正常运行的根本原因是什么?感谢所有建议

I wonder why did it happen and what is the root cause that prevents it from running properly in production server, while it works on my personal computer. Any advice is appreciated

    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


解决方案

您的服务器进程已收到 SIGPIPE 写入套接字。当您写入另一端(客户端)完全关闭的套接字时,通常会发生这种情况。当客户端程序不等到接收到来自服务器的所有数据而只是关闭套接字(使用 close 函数)时,就可能发生这种情况。

Your server process has received a SIGPIPE writing to a socket. This usually happens when you write to a socket fully closed on the other (client) side. This might be happening when a client program doesn't wait till all the data from the server is received and simply closes a socket (using close function).

在C程序中,通常会尝试设置忽略 SIGPIPE 信号或为其设置虚拟信号处理程序。在这种情况下,写入关闭的套接字时将返回一个简单的错误。在您的情况下,Python似乎抛出了一个异常,该异常可以作为客户端的过早断开连接来处理。

In a C program you would normally try setting to ignore SIGPIPE signal or setting a dummy signal handler for it. In this case a simple error will be returned when writing to a closed socket. In your case a python seems to throw an exception that can be handled as a premature disconnect of the client.

这篇关于如何防止errno 32管道破裂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆