sockjs-tornado
sockjs-tornado copied to clipboard
occasional exception when closing a connection
I have a disconnect_all method that goes through all the clients and call their close method. Sometimes, when using this method, I get the following exception:
ERROR 18-11-2015 00:00:03 Closing realtime channel Traceback (most recent call last): File "./server.py", line 173, in cleanup File "./handlers/RealtimeHandler.py", line 110, in disconnect_all File "/opt/ve/python-2.7.6/lib/python2.7/site-packages/sockjs/tornado/conn.py", line 65, in close self.session.close() File "/opt/ve/python-2.7.6/lib/python2.7/site-packages/sockjs/tornado/session.py", line 376, in close self.handler.send_pack(proto.disconnect(code, message)) File "/opt/ve/python-2.7.6/lib/python2.7/site-packages/sockjs/tornado/transports/xhrstreaming.py", line 45, in send_pack self.write(message + '\n') File "/opt/ve/python-2.7.6/lib/python2.7/site-packages/tornado/web.py", line 655, in write raise RuntimeError("Cannot write() after finish(). May be caused " RuntimeError: Cannot write() after finish(). May be caused by using async operations without the @asynchronous decorator.
Since I'm closing the connection it doesn't bother me much, but I guess it should be dealt with.