diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-10-21 12:14:34 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-10-21 12:14:34 (GMT) |
commit | 550841253fc237f7aed14663de9717d6313e340d (patch) | |
tree | 0bb9115171c114ec751231741b159f15d6ff3fc3 /Lib/wsgiref | |
parent | 8cd45bd48d495a78280e8c8c9377a9a9d4372bb2 (diff) | |
parent | 66510fedb410804b224360c6bf75041920b77709 (diff) | |
download | cpython-550841253fc237f7aed14663de9717d6313e340d.zip cpython-550841253fc237f7aed14663de9717d6313e340d.tar.gz cpython-550841253fc237f7aed14663de9717d6313e340d.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.py | 12 |
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): |