Merge "Close iterables at the end of iteration"
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user