Python的问题解决: IOError: [Errno 32] Broken pipe

简介:

错误一:

遇到一个很奇怪的问题, web.py代码里面报错

1
IOError: [Errno  32 ] Broken pipe

启动命令: 

1
nohup python xxx.py >> xxx.log &

ssh登录到机器上, 启动, 不会出现

远程ssh执行启动脚本, 就会出现IOError问题


查看进程pid, ll /proc/<pid>/fd 发现, stderr也就是fd为2的文件, 竟然是个pipe, 是个broken pipe, 错误的地方找到了


猜测可能是ssh登录过去, nohup会redirect stderr, 默认重定向到stdout, 不过ssh会话的stdout应该是pipe, 因为需要把输出从远端机器回传到本机

nohup把stderr重定向到了这个pipe上, 当ssh会话结束时, pipe自然会被关闭, 这样当程序代码中往stderr里面写入东西的时候, 就会报错了


错误二:


针对以上问题单机执行时候,发现不再报错,但是为了一定的处理,前面使用nginx作为反向代理,结果又出现

1
IOError: [Errno  32 ] Broken pipe


通过F12 发现,post 加载某个js 文件超时,并出现504 Time-out

检查js文件没有问题,

回忆,之前没有使用nginx前,此问题已经解决,为何突然又出现,

经过资料查询,使用以上nginx 配置解决

应该是读取时间设置过短,导致超时:

1
2
3
4
5
location  /  {
             proxy_read_timeout  300 ;
             ......
             .....
            }

这种问题,让人蛋疼。



      本文转自crazy_charles 51CTO博客,原文链接:http://blog.51cto.com/douya/1836848,如需转载请自行联系原作者



相关文章
|
2月前
|
安全 网络安全 API
python调用openai api报错self._sslobj.do_handshake()OSError: [Errno 0] Error
python调用openai api报错self._sslobj.do_handshake()OSError: [Errno 0] Error
74 1
python调用openai api报错self._sslobj.do_handshake()OSError: [Errno 0] Error
|
8月前
python-- 进程管道 Pipe、进程 Manager
python-- 进程管道 Pipe、进程 Manager
|
Docker Python 容器
解决docker 2022-11-16 14:54:26 python: can‘t open file ‘/src/main.py‘: [Errno 2]
解决docker 2022-11-16 14:54:26 python: can‘t open file ‘/src/main.py‘: [Errno 2]
131 0
|
Python
用python解决养兔子趣味问题
今天看到了一个很有趣的养兔子问题,决定尝试一下,各位大佬如果有其他思路,欢迎交流,在评论区写下你的想法哦!
313 0
用python解决养兔子趣味问题
|
存储 Python
python2:open()文件名为中文,报错IOError: [Errno 22] invalid mode ('w') or filename
python2:open()文件名为中文,报错IOError: [Errno 22] invalid mode ('w') or filename
406 0
|
数据处理 Python
帅到爆炸!使用管道 Pipe 编写 Python 代码竟如此简洁
众所周知,Pytnon 非常擅长处理数据,尤其是后期数据的清洗工作。今天派森酱就给大家介绍一款处理数据的神器 Pipe。
353 0
Python遇到的问题:IndentationError: expected an indented block
Python遇到的问题:IndentationError: expected an indented block
|
Python
python: not found 问题的解决
python: not found 问题的解决
644 0
|
Python
Python—Python 问题
离线安装库
110 0