0

I develop instant messaging application based on sockjs-tornado chat sample. My code is asynchronous.

Having this stack trace:

ERROR:root:Exception in callback <tornado.stack_context._StackContextWrapper object at 0x80932c788>
Traceback (most recent call last):

File "/usr/local/lib/python2.7/site-packages/tornado/ioloop.py", line 421, in _run_callback
    callback()

File "/usr/local/lib/python2.7/site-packages/tornado/iostream.py", line 305, in wrapper
    callback(*args)

File "/usr/local/lib/python2.7/site-packages/sockjs/tornado/websocket.py", line 661, in _on_frame_data
    self._receive_frame()

File "/usr/local/lib/python2.7/site-packages/sockjs/tornado/websocket.py", line 580, in _receive_frame
    self.stream.read_bytes(2, self._on_frame_start)

File "/usr/local/lib/python2.7/site-packages/tornado/iostream.py", line 166, in read_bytes
    self._try_inline_read()

File "/usr/local/lib/python2.7/site-packages/tornado/iostream.py", line 382, in _try_inline_read
    self._check_closed()

File "/usr/local/lib/python2.7/site-packages/tornado/iostream.py", line 565, in _check_closed
    raise IOError("Stream is closed")
IOError: Stream is closed

What is the way to handle this exception in case I have to remove reference to closed connection from chat participants list?

Thanks

stirbu
  • 3
  • 2
  • 1
    [you can see here similar situation][1] [1]: http://stackoverflow.com/questions/11161626/tornado-server-throws-error-stream-is-closed – stirbu Dec 10 '12 at 22:06
  • @stirbu: format that as `[you can see here similar situation](http://stackoverflow.com/questions/11161626/tornado-server-throws-error-stream-is-closed)`. – BrtH Dec 10 '12 at 23:23

1 Answers1

0

This exception happens when user drops websocket connection without properly closing it (networking error, etc).

In either case, your on_close handler will be called so you can remove user from the chat participant list.

Joes
  • 1,808
  • 14
  • 8