]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Call the close() method on the wsgi response object if it exists.
authorBen Darnell <bdarnell@beaker.local>
Sat, 27 Feb 2010 00:36:21 +0000 (16:36 -0800)
committerBen Darnell <bdarnell@beaker.local>
Sat, 27 Feb 2010 00:36:21 +0000 (16:36 -0800)
This is required by the WSGI spec, and cherrypy leaks memory without it.

tornado/wsgi.py

index f3bc71767bf74f8cc2b7fc426186098a9fe340ff..fca3b35f6dc8fe16e40a264bef00ca66cbfa7678 100644 (file)
@@ -213,8 +213,11 @@ class WSGIContainer(object):
         def start_response(status, response_headers, exc_info=None):
             data["status"] = status
             data["headers"] = HTTPHeaders(response_headers)
-        body = "".join(self.wsgi_application(
-            WSGIContainer.environ(request), start_response))
+        response = self.wsgi_application(
+            WSGIContainer.environ(request), start_response)
+        body = "".join(response)
+        if hasattr(response, "close"):
+            response.close()
         if not data: raise Exception("WSGI app did not call start_response")
 
         status_code = int(data["status"].split()[0])