Closed mmcclellan closed 8 years ago
If you want to be a little more discriminating in your exception catching you can do:
from geventwebsocket import WebSocketError
while True:
try:
ws.send("some data")
except WebSocketError as e:
print('Caught WebSocketError: %s' % e)
break
It's best to do while not ws.closed
.
@kennethreitz while not ws.closed
isn't enough in some situations. try: ... except WebSocketError:
still helps.
If I change the example code to this:
All works well. Otherwise I get WebSocketErrors when the client disconnects. Not sure if others have experienced this.