WebSocket-for-Python icon indicating copy to clipboard operation
WebSocket-for-Python copied to clipboard

close_connection doesn't close() because sock.shutdown crashes first.

Open EternityForest opened this issue 4 years ago • 0 comments

When using cherrypy and ssl, for reasons I don't understand, the sock.shutdown call throws this error occasionally(When the source is modified to print tracebacks instead of silently pass).

Traceback (most recent call last):
  File "/home/daniel/Projects/KaithemAutomation/kaithem/src/thirdparty/ws4py/websocket.py", line 210, in close_connection
    self.sock.shutdown(socket.SHUT_RDWR)
  File "/usr/lib/python3.6/ssl.py", line 1050, in shutdown
    socket.shutdown(self, how)
OSError: [Errno 107] Transport endpoint is not connected

Seeing as how this is in the same try/except block as socket.close(), I presume that socket.close() is not always being called. Because of circular refs it might or might not get GCed right away, and if it does not, it may have something to do with some of the remaining bad behavior.

I will be testing with giving shutdown it's own try/except block and seeing how that goes.

EternityForest avatar Aug 19 '19 08:08 EternityForest