]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Close wsgi responses correctly - the close method, if present, will
authorBen Darnell <bdarnell@beaker.local>
Fri, 18 Jun 2010 22:59:19 +0000 (15:59 -0700)
committerBen Darnell <bdarnell@beaker.local>
Fri, 18 Jun 2010 22:59:19 +0000 (15:59 -0700)
be on the result of self.wsgi_application() and not on the list
of output we're building up.

tornado/wsgi.py

index 181429cb32310c900bd05e2a8396dde34aa146e7..4aaa5fb73490f0190de0583ace51f02ad252d90f 100644 (file)
@@ -219,11 +219,12 @@ class WSGIContainer(object):
             data["status"] = status
             data["headers"] = response_headers
             return response.append
-        response.extend(self.wsgi_application(
-                WSGIContainer.environ(request), start_response))
+        app_response = self.wsgi_application(
+            WSGIContainer.environ(request), start_response)
+        response.extend(app_response)
         body = "".join(response)
-        if hasattr(response, "close"):
-            response.close()
+        if hasattr(app_response, "close"):
+            app_response.close()
         if not data: raise Exception("WSGI app did not call start_response")
 
         status_code = int(data["status"].split()[0])