python gevent websocket中出现套接字已死异常

问题描述

We got socket is dead exception

Socket 连接目的我们使用 gevent websocket。我们正在使用 opencv、gevent websocket、android apk 获取帧。在运行我们的 python 文件时,我们得到了 socket is dead 异常。

if request.environ.get('wsgi.websocket'):
    ws = request.environ['wsgi.websocket']
    try:
            cam_ip = 0
            cap = cv2.VideoCapture(cam_ip)
            while True:
                ret,frame = cap.read()

                if ret==True:
                    ws.send(frame)
               
                 else:
                    raise Exception('Frames are not captured')
                    break

            cap.release()
            cv2.destroyAllWindows()

    except Exception as e:
        print(e)
return

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)