Memory leak/no exception on send over closed socket
I've got this simple gevent+websocket server running with pyzmq:
The problem is down at line 165:
# This will block until messages arrive. system_id = subscriber.recv() # Send the message ws.send(system_id)
This blocks while waiting for data to come down the pipe. When we get it, the next line down sends said data out over websockets.
The problem is, it seems like even if someone disconnects/closes their browser, as soon as we receive data and hit ws.send(), it pretends like everything is OK, and doesn't appear to raise an Exception to let me know that the socket is closed, and I need to kill the greenlet.
This means that I gradually accumulate unclosed socket objects as people visit the site, causing my gradually run out of memory.
I'm stumped, and would hate to have to write this in Twisted, since this looks so much nicer. Any ideas would be awesome.