]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
WSGI specification requires that close() be called on iterable no matter what happens. 824/head
authorGraham Dumpleton <Graham.Dumpleton@gmail.com>
Mon, 17 Jun 2013 05:49:42 +0000 (15:49 +1000)
committerGraham Dumpleton <Graham.Dumpleton@gmail.com>
Mon, 17 Jun 2013 05:49:42 +0000 (15:49 +1000)
tornado/wsgi.py

index 6b5bfb8f6a0746328667ae0ae6ecd0569fdf8dec..5e25a5647ae2c82335165dff1f296083834b0724 100644 (file)
@@ -242,10 +242,12 @@ class WSGIContainer(object):
             return response.append
         app_response = self.wsgi_application(
             WSGIContainer.environ(request), start_response)
-        response.extend(app_response)
-        body = b"".join(response)
-        if hasattr(app_response, "close"):
-            app_response.close()
+        try:
+            response.extend(app_response)
+            body = b"".join(response)
+        finally:
+            if hasattr(app_response, "close"):
+                app_response.close()
         if not data:
             raise Exception("WSGI app did not call start_response")