Merge "Close iterables at the end of iteration"

This commit is contained in:
Jenkins
2015-06-16 19:01:18 +00:00
committed by Gerrit Code Review
2 changed files with 18 additions and 1 deletions
+5 -1
View File
@@ -442,7 +442,11 @@ class IterableWithLength(object):
self.length = length
def __iter__(self):
return self.iterable
try:
for chunk in self.iterable:
yield chunk
finally:
self.iterable.close()
def next(self):
return next(self.iterable)