php sigpipe,Python的SIGPIPE信号「建议收藏」

php sigpipe,Python的SIGPIPE信号「建议收藏」Haveyoueverseenasocket.error:[Errno32]BrokenpipemessagewhenrunningaPythonWebserverandwonderedwhatthatmeans?Theruleisthatwhenaprocesstriestowritetoasocketthathasalre…

大家好,又见面了,我是你们的朋友全栈君。

Have you ever seen a socket.error: [Errno 32] Broken pipe message when running a Python Web server and wondered what that means?

The rule is that when a process tries to write to a socket that has already received an RST packet, the SIGPIPE signal is sent to that process which causes the Broken pipe socket.error exception.

Here are two scenarios that you can try that cause SIGPIPE signal to be fired.

1. Server may send an RST packet to a client to abort the socket connection but the client ignores the packet and continues to write to the socket.

To test that behavior. install Cynic, run it

CODE:01.$ cynic

02.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPHtmlResponse’   on port 2000

03.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPJsonResponse’   on port 2001

04.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPNoBodyResponse’ on port 2002

05.INFO     [2012-06-08 05:06:37,040] server: Starting ‘HTTPSlowResponse’   on port 2003

06.INFO     [2012-06-08 05:06:37,040] server: Starting ‘RSTResponse’        on port 2020

07.INFO     [2012-06-08 05:06:37,040] server: Starting ‘RandomDataResponse’ on port 2021

08.INFO     [2012-06-08 05:06:37,040] server: Starting ‘NoResponse’         on port 2022

09.INFO     [2012-06-08 05:06:37,041] server: Starting ‘LogRecordHandler’   on port /tmp/_cynic.sockand then run the client1.py:

CODE:01.import socket

02.

03.# connect to Cynic’s RSTResponse service on port 2020

04.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

05.s.connect((”, 2020))

06.

07.# first read gets an RST packet

08.try:

09.s.recv(1024)

10.except socket.error as e:

11.print e

12.print

13.

14.# write after getting the RST causes SIGPIPE signal

15.# to be sent to this process which causes a socket.error

16.# exception

17.s.send(‘hello’)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/301743/viewspace-733074/,如需转载,请注明出处,否则将追究法律责任。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/139298.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Java二维数组的输出

    Java二维数组的输出Java二维数组的输出<1>(1)输出结果右对齐”%5d”publicclassHelloWorld{publicstaticvoidmain(String[]args){intmyArray[][]={{1,2},{7,2},{3,4}};for(inti=0;i<3;i++){for(intj=0;j<2;j++)System.out.p..

    2022年6月1日
    32
  • 海量数据挖掘MMDS week3:社交网络之社区检测:基本技巧「建议收藏」

    http://blog.csdn.net/pipisorry/article/details/49052057海量数据挖掘MiningMassiveDatasets(MMDs)-JureLeskovec courses学习笔记之社交网络之社区检测:基本技巧-生成模型及其参数的梯度上升方法求解博客内容:社区检测的基本技巧部分,覆盖”overlappingcommunities”寻找最好集合

    2022年4月13日
    118
  • 【解决】E: 无法获取 dpkg 前端锁 (/var/lib/dpkg/lock-frontend)「建议收藏」

    【解决】E: 无法获取 dpkg 前端锁 (/var/lib/dpkg/lock-frontend)「建议收藏」【解决】E:无法获取dpkg前端锁(/var/lib/dpkg/lock-frontend),是否有其他进程正占用它?1常用两个方法https://blog.csdn.net/qq_38019633/article/details/840243092以上不行时候,用这种更新软件库sudoapt-getupdate继续进行安装解决…

    2022年10月6日
    3
  • freemarker map 判断是否为空「建议收藏」

    freemarker map 判断是否为空「建议收藏」记录一下freemarker学习中的一些重要知识点。

    2022年6月16日
    80
  • 开源版本Visifire的应用「建议收藏」

    开源版本Visifire的应用「建议收藏」Visifire曾经开源,保持使用开源版本是不会有版权问题滴。引用的命名控件usingVisifire.Charts;usingVisifire.Commons;一、应用示例主要代码//

    2022年7月4日
    26
  • Hystrix:服务熔断

    Hystrix:服务熔断文章目录服务雪崩服务雪崩​多个微服务之间调用的时候,假设微服务A调用微服务B和微服务C,微服务B和微服务C又调用其他的微服务,这就是所谓的“扇出”,如果扇出的链路上某个微服务的调用响应时间过长,或者不可用,对微服务A的调用就会占用越来越多的系统资源,进而引起系统崩溃,所谓的“雪崩效应”。​对于高流量的应用来说,单一的后端依赖可能会导致所有服务器上的所有资源都在几十秒内饱和。比失败更糟糕的是,这些应用程序还可能导致服务之间的延迟增加,备份队列,线程和其他系统资源紧张,导致整个系统发生更多的级联故障,

    2022年10月21日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号