Loading

gevent BrokenPipeError[未解决]

gevent BrokenPipeError
报错内容:

Traceback (most recent call last):
  File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
  File "/mnt/d/work/code/api-testing/utils/ws_request2.py", line 104, in run
    ws.send(json.dumps(message))
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/websocket/_app.py", line 191, in send
    if not self.sock or self.sock.send(data, opcode) == 0:
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/websocket/_core.py", line 282, in send
    return self.send_frame(frame)
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/websocket/_core.py", line 310, in send_frame
    l = self._send(data)
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/websocket/_core.py", line 514, in _send
    return send(self.sock, data)
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/websocket/_socket.py", line 175, in send
    return _send()
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/websocket/_socket.py", line 152, in _send
    return sock.send(data)
  File "/home/test/.local/share/virtualenvs/api-testing-_AH93AeQ/lib/python3.8/site-packages/gevent/_socket3.py", line 515, in send
    return self._sock.send(data, flags)
BrokenPipeError: [Errno 32] Broken pipe
2021-06-21T08:50:23Z <Greenlet at 0x7f1fd0307370: run> failed with BrokenPipeError


  1. 忽略错误
    还是不能继续发送msg
import socket
import errno

try:
    self.ws.send(json.dumps(message))
except socket.error as e:
    if e.errno != errno.EPIPE:
     Not a broken pipe
        raise
    print(e,'ignore')

2.开启websocket enabletrace 发现websocket 断开连接了...
尝试添加判断 if self.ws.sock is not None:
发现这个不太对....发送失败才主动断开连接的...没找到怎么判断websocket状态的代码...

  1. window上执行没有报错,环境问题?
    更改了gevent为指定版本,不行。。。。本地根本没有安装这个
    难道是python版本,本地版本是3.9.5

  2. 安装python3.9

根据教程安装,如果permission deny,全部加上sudo就好了。。。
问题:

Makefile:1254: recipe for target 'install' failed
make: *** [install] Error 1

解决方案参考: Debian 9安装 Python3.7 遇见的环境问题

安装完成:

Installing collected packages: setuptools, pip
  WARNING: The script easy_install-3.9 is installed in '/usr/local/python3.9/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts pip3 and pip3.9 are installed in '/usr/local/python3.9/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.3 setuptools-49.2.1

出现新问题: pipenv sync 报错pip is configured with locations that require TLS/SSL

解决pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
wget https://github.com/openssl/openssl/releases/tag/openssl-3.0.0-beta1

问题到此还是为解决,如果小伙伴有解决方案可以在评论区告知一下~
哦~还试过全局ignore,但是...failed...具体参考Linux下send函数 Broken pipe错误的解决方法

环境

Ubuntu 18.04LTS

python 3.9.0
pipenv, version 2021.5.29
pip 21.1.2 
black==21.6b0
locust==1.5.3
pytest-assume==2.4.2
pytest-html==2.1.1
pytest-rerunfailures==10.0
PyYAML==5.4.1
websocket-client==1.1.0
gevent==20.9.0

上面的内容,主要还是一些知识点整理和个人的一些思考,权当参考,如有错误或者更好的建议,可以在评论区指正,不胜感激!

posted @ 2021-06-22 10:18  Tester-Dolores  阅读(288)  评论(0编辑  收藏  举报