From 2b44fac4ecf273aadc97dbcaa5abf1e3a1ee7dff Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Thu, 4 Nov 2010 11:47:34 -0700 Subject: [PATCH] Check for a closed connection in _add_io_state. Closes #163. --- tornado/iostream.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tornado/iostream.py b/tornado/iostream.py index 2897fdc7..4f321d55 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -359,6 +359,9 @@ class IOStream(object): raise IOError("Stream is closed") def _add_io_state(self, state): + if socket is None: + # connection has been closed, so there can be no future events + return if not self._state & state: self._state = self._state | state self.io_loop.update_handler(self.socket.fileno(), self._state)