0

我基于 sockjs-tornado 聊天示例开发了即时消息应用程序。我的代码是异步的。

有这个堆栈跟踪:

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

如果我必须从聊天参与者列表中删除对已关闭连接的引用,如何处理此异常?

谢谢

4

1 回答 1

0

当用户断开 websocket 连接而没有正确关闭它(网络错误等)时,会发生此异常。

在任何一种情况下,on_close都会调用您的处理程序,以便您可以从聊天参与者列表中删除用户。

于 2012-12-31T08:31:08.453 回答