Skip to content

Commit

Permalink
Clear the close_callback set on the IOStream by RequestHandlers in
Browse files Browse the repository at this point in the history
finish(), so that the close_callback does not prevent garbage collection
of the handlers.

http://github.com/facebook/tornado/issues/issue/95/
  • Loading branch information
Ben Darnell committed May 31, 2010
1 parent 5d430b1 commit 6f6c950
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tornado/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ def finish(self, chunk=None):
content_length = sum(len(part) for part in self._write_buffer)
self.set_header("Content-Length", content_length)

if hasattr(self.request, "connection"):
# Now that the request is finished, clear the callback we
# set on the IOStream (which would otherwise prevent the
# garbage collection of the RequestHandler when there
# are keepalive connections)
self.request.connection.stream.set_close_callback(None)

if not self.application._wsgi:
self.flush(include_footers=True)
self.request.finish()
Expand Down

0 comments on commit 6f6c950

Please sign in to comment.