I'm using cherrypy and ws4py.
If the browser cut the websocket connection, any write in def received_message(self, m):
would raise an error,
Exception in thread Thread-1:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/Library/Python/2.7/site-packages/ws4py/manager.py", line 310, in run
if not ws.once():
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 388, in once
if not self.process(b):
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 445, in process
self.close(s.closing.code, s.closing.reason)
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 189, in close
self._write(self.stream.close(code=code, reason=reason).single(mask=self.stream.always_mask))
File "/Library/Python/2.7/site-packages/ws4py/websocket.py", line 279, in _write
self.sock.sendall(b)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
error: [Errno 32] Broken pipe
How can I tell if the connection is closed?