: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. angualr4 环境搭建

    不得不说现在很流行前端MVC框架,angularjs算是一种.以前也用过angularjs感觉还不错,刷新了我对前端的认知.特别是因为我本身是个java开发.但是感觉还是有很多缺点的,直到angula ...

  2. 前端之JavaScript 03

    window对象 所有浏览器都支持 window 对象.概念上讲.一个html文档对应一个window对象.功能上讲: 控制浏览器窗口的.使用上讲: window对象不需要创建对象,直接使用即可. W ...

  3. INIT: vesion 2.88 booting

    /***************************************************************************** * INIT: vesion 2.88 b ...

  4. (九)jsMath

    1.Math对象 作用:用于执行数学任务,把Math作为对象就可以调用其方法和属性. eg:    typeof Math); 2.Math属性     PI:圆周率(约等于 3.1415926); ...

  5. Android sharedUserId 使用

    在Android 系统中,所有安装到系统的应用程序都必有一个数字证书,此数字证书用于标识应用程序的作者和在应用程序之间建立信任关系,.这个数字证书并不需要权威的数字证书签名机构认证,它只是用来让应用程 ...

  6. C++多态技术

    转自:    http://blog.sciencenet.cn/blog-58025-691458.html 摘要 本文介绍了C++中的各种多态性,重点阐述了面向对象的动态多态和基于模板的静态多态, ...

  7. matlab中freqz的用法以及多项式的展开

    对于一个变量a,matlab中定义需要这样 syms a: 定义之后就可以写由变量组成的式子,比如 c=(1+a^-1)^5; 可以用expand(c) 就能把c展开成多项式,每一项的系数就可以看到. ...

  8. 谨慎安装Python3.7.0,SSL低版本导致Pip无法使用

    最新新配置了一台服务器.安装 的时候直接使用了最新的Python 3.7最新版本. 安装成功,编译成功.但是用pip 安装包的时候提示:pip is configured with locations ...

  9. (转)Android开发--常用的传感器总结

    随着手机的发展,现在各大手机支持的传感器类型也越来越多,在开发中利用传感器进行某些操作令人们有一种耳目一新的感觉,例如微信中的摇一摇,以及手机音乐播放器中的摇一摇切歌.今天来简单介绍下Android中 ...

  10. html网页自动跳转页面代码

    方案一,用<meta>里直接写刷新语句: <html><head><meta http-equiv="Content-Language" ...