From: Ben Darnell Date: Mon, 31 May 2010 05:50:11 +0000 (-0700) Subject: Clear the close_callback set on the IOStream by RequestHandlers in X-Git-Tag: v1.0.0~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f6c95054fd98998aa47bd1dbed3c1e9a81b33dd;p=thirdparty%2Ftornado.git Clear the close_callback set on the IOStream by RequestHandlers in finish(), so that the close_callback does not prevent garbage collection of the handlers. http://github.com/facebook/tornado/issues/issue/95/ --- diff --git a/tornado/web.py b/tornado/web.py index 42476e73b..7bd6f86be 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -512,6 +512,13 @@ class RequestHandler(object): 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()