:first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0; } table { border-collapse: collapse; border: 1px solid #bbbbbb; } td, th { padding: 4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb; } @media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; } }
-->

div{font-size:15px;}.wiz-table-tools .wiz-table-menu-item.active .wiz-table-menu-sub {display: block}.wiz-table-tools .wiz-table-menu-sub:before, .wiz-table-tools .wiz-table-menu-sub:after {position: absolute;content: " ";border-style: solid;border-color: transparent;border-bottom-color: #cccccc;left: 22px;margin-left: -14px;top: -8px;border-width: 0 8px 8px 8px;z-index:10;}.wiz-table-tools .wiz-table-menu-sub:after {border-bottom-color: #ffffff;top: -7px;}.wiz-table-tools .wiz-table-menu-sub-item {padding: 4px 12px;font-size: 14px;}.wiz-table-tools .wiz-table-menu-sub-item.split {border-top: 1px solid #E0E0E0;}.wiz-table-tools .wiz-table-menu-sub-item:hover {background-color: #ececec;}.wiz-table-tools .wiz-table-menu-sub-item.disabled {color: #bbbbbb;cursor: default;}.wiz-table-tools .wiz-table-menu-sub-item.disabled:hover {background-color: transparent;}.wiz-table-tools .wiz-table-menu-item.wiz-table-cell-bg:hover .wiz-table-color-pad {display: block;}.wiz-table-tools .wiz-table-color-pad {display: none;padding: 10px;box-sizing: border-box;width: 85px;height: 88px;background-color: #fff;cursor: default;}.wiz-table-tools .wiz-table-color-pad > div{font-size:15px;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item {display: inline-block;width: 15px;height: 15px;margin-right: 9px;position: relative;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item i.pad-demo {position: absolute;top:3px;left:0;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item .icon-oblique_line{color: #cc0000;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item:last-child {margin-right: 0;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item.active i.editor-icon.icon-box {color: #448aff;}.wiz-table-tools .wiz-table-cell-align {display: none;padding: 10px;box-sizing: border-box;width: 85px;height: 65px;background-color: #fff;cursor: default;}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item {display: inline-block;width: 15px;height: 15px;margin-right: 9px;position: relative;}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item:last-child {margin-right:0}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item i.valign{position: absolute;top:3px;left:0;color: #d2d2d2;}.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.valign {color: #a1c4ff;}.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.icon-box,.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.align {color: #448aff;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item:last-child,.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item:last-child {margin-right: 0;}th.wiz-selected-cell-multi, td.wiz-selected-cell-multi {background: rgba(0,102,255,.05);}th:before,td:before,#wiz-table-col-line:before,#wiz-table-range-border_start_right:before,#wiz-table-range-border_range_right:before{content: " ";position: absolute;top: 0;bottom: 0;right: -5px;width: 9px;cursor: col-resize;background: transparent;z-index:100;}th:after,td:after,#wiz-table-row-line:before,#wiz-table-range-border_start_bottom:before,#wiz-table-range-border_range_bottom:before{content: " ";position: absolute;left: 0;right: 0;bottom: -5px;height: 9px;cursor: row-resize;background: transparent;z-index:100;}.wiz-table-container {}.wiz-table-body {position:relative;padding:0 0 10px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;}.wiz-table-body table {margin:0;outline:none;}td,th {height:28px;word-break:break-all;box-sizing:border-box;outline:none;}body pre.prettyprint {padding:0;}body pre.prettyprint code {white-space: pre;}body pre.prettyprint.linenums {box-shadow:none; overflow: auto;-webkit-overflow-scrolling: touch;}body pre.prettyprint.linenums ol.linenums {box-shadow: 40px 0 0 #FBFBFC inset, 41px 0 0 #ECECF0 inset; padding: 10px 10px 10px 40px !important;}
-->

Flask 出现 "Broken pipe" 现象说明:
采用 Flask 原生 WSGI 发布 Web(app.run())。随后,发起一个 Request,在 Request 还未返回前停止查询,并重新发起一个新的 Request。服务端很可能出现类似如下的"Broken pipe"报错。
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usrb64/python2.7/threading.py", line 811, in __bootstrap_inner
    self.run()
  File "/usrb64/python2.7/threading.py", line 764, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 659, in inner
    srv.serve_forever()
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 499, in serve_forever
    HTTPServer.serve_forever(self)
  File "/usrb64/python2.7/SocketServer.py", line 238, in serve_forever
    self._handle_request_noblock()
  File "/usrb64/python2.7/SocketServer.py", line 297, in _handle_request_noblock
    self.handle_error(request, client_address)
  File "/usrb64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usrb64/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usrb64/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usrb64/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 216, in handle
    rv = BaseHTTPRequestHandler.handle(self)
  File "/usrb64/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 251, in handle_one_request
    return self.run_wsgi()
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 193, in run_wsgi
    execute(self.server.app)
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 184, in execute
    write(data)
  File "/usrb/python2.7/site-packages/werkzeugrving.py", line 152, in write
    self.send_header(key, value)
  File "/usrb64/python2.7/BaseHTTPServer.py", line 401, in send_header
    self.wfile.write("%s: %s\r\n" % (keyword, value))
IOError: [Errno 32] Broken pipe
 

"Broken pipe" 报错原因:<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

 
 
 
 
"Broken pipe" 的字面意思为 "管道破裂",本质为写入端反馈时读端却关闭,因而造成没有及时取走管道中的数据,从而引发程序异常。
 
"Broken pipe" 报错处理方式:
放弃对 Flask 原生 WSGI 的使用,转而使用全功能的 WSGI,例如:gunicorn、uWSGI 等。
 
多种 WSGI 对引发 "Broken pip" 报错操作的响应对比:
1.Flask 原生 WSGI
采用 Flask 原生 WSGI 的最简测试程序如下。
from flask import Flask
                                                                          
app = Flask(__name__)
                                                                             
@app.route('/')
def index():
    import time
    time.sleep(10)
    return 'Hello World'
                                   
app.run(host='11.4.76.73', port=6001)
调用方式如下。
# ./env/bin/python flasktest.py
当发起一个 Request,在 Request 还未返回前停止查询,并重新发起一个新的 Request时,WSGI 响应类似如下。

注意:报错"Broken pipe",程序崩溃
2.gunicorn
采用 gunicorn 的最简测试程序如下。
from flask import Flask
                                     
app = Flask(__name__)
                                       
@app.route('/')
def index():
    import time
    time.sleep(10)
    return 'Hello World'
调用方式如下。
# ./env/bin/gunicorn -w 1 --log-level 'debug' -b 11.4.76.73:6002 gunicorntest:app
当发起一个 Request,在 Request 还未返回前停止查询,并重新发起一个新的 Request时,WSGI 响应类似如下。

注意:出现"Ignoring connection reset"信息,但不影响应用运行。
3.pywsgi
采用 pywsgi 的最简测试程序如下。
from gevent import monkey
monkey.patch_all()
from flask import Flask
from gevent import pywsgi
                                       
app = Flask(__name__)
                                       
@app.route('/')
def index():
    import time
    time.sleep(10)
    return 'Hello World'
                                   
server = pywsgi.WSGIServer(('11.4.76.73', 6003), app)
server.serve_forever()
调用方式如下。
# ./env/bin/python geventtest.py
当发起一个 Request,在 Request 还未返回前停止查询,并重新发起一个新的 Request时,WSGI 响应类似如下。
注意:应用正常。

因采用 Flask 原生 WSGI 出现 "Broken pipe" 报错的故障处理的更多相关文章

  1. broken pipe 报错分析和解决办法

    参考资料: 1.博客1:https://blog.csdn.net/qq_37535749/article/details/113781338 2.博客2:https://blog.csdn.net/ ...

  2. flask+sqlite3+echarts2+ajax数据可视化报错:UnicodeDecodeError: 'utf8' codec can't decode byte解决方法

    flask+sqlite3+echarts2+ajax数据可视化报错: UnicodeDecodeError: 'utf8' codec can't decode byte 解决方法: 将 py文件和 ...

  3. flask笔记(三)Flask 添加登陆验证装饰器报错,及解析

    Flask 添加登陆验证装饰器报错,及解析 写这个之前,是想到一个需求,这个是关于之前写Flask笔记(二)中的一个知识点,路由相关 需求为 : 有一些页面必须是登陆之后才能访问的,比如Shoppin ...

  4. Flask - 访问返回字典的接口报错:The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a dict.

    背景 有一个 Flask 项目,然后有一个路由返回的是 dict 通过浏览器访问,结果报错 关键报错信息 TypeError: 'dict' object is not callable The vi ...

  5. from flask.ext.wtf import Form导入报错

    问题来源: 在学习Flask网上教程(PS:中文版教程链接,英文版教程其中代码是对的,运行没错误,我为了看的快一些,所以就直接看的中文版>~<,英文版教程链接)时,使用如下代码: from ...

  6. Python直接改变实例化对象的列表属性的值 导致在flask中接口多次请求报错

    错误原理实例如下: class One(): list = [1, 2, 3] @classmethod def get_copy_list(cls): # copy一份list,这样对list的改变 ...

  7. 解决thinkphp query()执行原生SQL语句成功结果报错的问题

    1.query方法 query方法用于执行SQL查询操作,如果数据非法或者查询错误则返回false,否则返回查询结果数据集(同select方法). 2.execute方法 execute用于更新和写入 ...

  8. 采用WebService客户端调用WSDL/SOAP网络报错的解决办法

    WebService接口是网络传输控制的重要途径,在Windows系统下运行客户端时,平时一直能正确运行,但某天可能突然会发生调用wsdl soap邮件标头无法识别等莫名其妙的错误提示,出现这种情况一 ...

  9. 首次接触flask遇到socket.error: [Errno 10013] 报错

    解决方案: 发现是因为端口5000被占用了,设置一个其他port就行:app.run(port=5050)

随机推荐

  1. Lua基础---流程控制语句

    Lua提供了if语句和if else语句作为流程控制语句,当然,符合C的特点,流程语句之间可以实现嵌套操作,当然流程控制也可以和循环体结合进行控制. 1.if语句 if(布尔表达式) then --[ ...

  2. 使用Reaver破解开启了WPS功能的wifi密码(wpa/wpa2)

    来自wikipeida: Wi-Fi保护设置(简称WPS,全称Wi-Fi Protected Setup)是一个无线网络安全标准,旨在让家庭用户使用无线网络时简化加密步骤.此标准由Wi-Fi联盟(Wi ...

  3. Windows GVLK密钥对照表(KMS激活专用

    以下key来源于微软官网:https://technet.microsoft.com/en-us/library/jj612867.aspx Windows Server 2016 操作系统 KMS激 ...

  4. (四)canvas绘制路径

    save() 样式不受污染的起始范围 shadowOffsetX 阴影x轴的距离 shadowOffsetY 阴影y轴的距离 shadowBlur 模糊度 shadowColor 阴影颜色 resto ...

  5. HDU - 6430:TeaTree (线段树合并)

    Recently, TeaTree acquire new knoledge gcd (Greatest Common Divisor), now she want to test you. As w ...

  6. vector释放内存之swap方法

    相信大家看到swap这个词都一定不会感到陌生,就是简单的元素交换.但swap在C++ STL中散发着无穷的魅力.下面将详细的说明泛型算法swap和容器中的swap成员函数的使用! 1. 泛型算法swa ...

  7. Django之模板继承

    为了在Django模板配置中减少代码的冗余,需使用模板继承 1. 语法 {% block classinfo %} {% endblock} 2. 步骤 (1)创建一个base.html把需要显示的页 ...

  8. Dreamweaver_CS6安装与破解

    Adobe Dreamweaver是一款非常好用的web前端设计工具,这里详细讲解CS6版本的安装及破解步骤.经过测试,CS5版本也可以使用本经验中共享的破解补丁进行破解. 工具/原料 Dreamwe ...

  9. 3625 codevs 士兵站队问题 中位数的妙用

    士兵站队问题 题目描述 Description 在一个划分成网格的操场上,n个士兵散乱地站在网格点上.网格点用整数坐标(x,y)表示.士兵们可以沿网格边往上.下.左.右移动一步,但在同一时刻任一网格点 ...

  10. 《笔者带你剖析Apache Commons DbUtils 1.6》(转)

    前言 关于Apache的DbUtils中间件或许了解的人并不多,大部分开发人员在生成环境中更 多的是依靠Hibernate.Ibatis.Spring JDBC.JPA等大厂提供的持久层技术解决方案, ...