]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Clear the close_callback set on the IOStream by RequestHandlers in
authorBen Darnell <bdarnell@beaker.local>
Mon, 31 May 2010 05:50:11 +0000 (22:50 -0700)
committerBen Darnell <bdarnell@beaker.local>
Mon, 31 May 2010 06:39:32 +0000 (23:39 -0700)
finish(), so that the close_callback does not prevent garbage collection
of the handlers.

http://github.com/facebook/tornado/issues/issue/95/

tornado/web.py

index 42476e73b1238961f13933bbea146fdd0446ad91..7bd6f86bebcf422dcd80e963a680e59106022e9b 100644 (file)
@@ -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()