Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
parente opened this Issue · 4 comments

4 participants

Peter Parente Ben Darnell Jon Parise 赵永强
Peter Parente

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

...
self.finish()
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/web.py", line 459, in finish
self.flush(include_footers=True)
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/web.py", 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/httpserver.py", line 286, in write
self.connection.write(chunk)
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/httpserver.py", line 126, in write
self.stream.write(chunk, self._on_write_complete)
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/iostream.py", line 111, in write
self._check_closed()
File "/home/parente/envs/jsonic/lib/python2.6/site-packages/tornado-0.2-py2.6.egg/tornado/iostream.py", line 223, in _check_closed
raise IOError("Stream is closed")
IOError: Stream is closed

Ben Darnell
Owner

This should no longer throw an exception.

Jon Parise

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 self.request.connection.stream.closed():
            super(RequestHandler, self).finish(chunk)

... but that's not ideal.

Ben Darnell
Owner

@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
Something went wrong with that request. Please try again.