summaryrefslogtreecommitdiffstats
path: root/Lib/wsgiref
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-10-21 12:09:05 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-10-21 12:09:05 (GMT)
commitae247a5ff6bd937f2049b2d403893d46840dfc21 (patch)
tree01cec3294190fbaeb7bc03bdd0761d1e7d3bee97 /Lib/wsgiref
parent2778d0d1477f854d7443075a21369fde2032d43c (diff)
downloadcpython-ae247a5ff6bd937f2049b2d403893d46840dfc21.zip
cpython-ae247a5ff6bd937f2049b2d403893d46840dfc21.tar.gz
cpython-ae247a5ff6bd937f2049b2d403893d46840dfc21.tar.bz2
Issue #16220: wsgiref now always calls close() on an iterable response.
Patch by Brent Tubbs.
Diffstat (limited to 'Lib/wsgiref')
-rw-r--r--Lib/wsgiref/handlers.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/wsgiref/handlers.py b/Lib/wsgiref/handlers.py
index 67064a6..63d5993 100644
--- a/Lib/wsgiref/handlers.py
+++ b/Lib/wsgiref/handlers.py
@@ -174,11 +174,13 @@ class BaseHandler:
in the event loop to iterate over the data, and to call
'self.close()' once the response is finished.
"""
- if not self.result_is_file() or not self.sendfile():
- for data in self.result:
- self.write(data)
- self.finish_content()
- self.close()
+ try:
+ if not self.result_is_file() or not self.sendfile():
+ for data in self.result:
+ self.write(data)
+ self.finish_content()
+ finally:
+ self.close()
def get_scheme(self):