IOError "Stream is closed" not caught in finish() #81

parente opened this Issue Apr 1, 2010 · 4 comments

4 participants


Is it expected that my handler should catch this exception? When it happens, the server goes into limbo and no longer handles requests.

File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/", line 459, in finish
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/", line 433, in flush
self.request.write(headers + chunk)
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/", line 286, in write
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/", line 126, in write, self._on_write_complete)
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/", line 111, in write
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/", line 223, in _check_closed
raise IOError("Stream is closed")
IOError: Stream is closed

tornadoweb member

This should no longer throw an exception.


Since upgrading to Tornado 2.4, I've seen these exceptions start to bubble up once again. I'm working around them in a RequestHandler subclass:

    def finish(self, chunk=None):
        if not
            super(RequestHandler, self).finish(chunk)

... but that's not ideal.

tornadoweb member

@jparise can you post a stack trace? (or open a new issue, since I think the exception is coming from a different place than in this two-year-old bug)


I have encounted the same problem when the client connection closed before the sever write.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment