summaryrefslogtreecommitdiff
path: root/glanceclient/common/utils.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-06-16 19:01:18 +0000
committerGerrit Code Review <review@openstack.org>2015-06-16 19:01:18 +0000
commit71d852836474f59f10a7bb9883f6dcecc56e5675 (patch)
treefc75ba7846126921d3fd3509404f2cd7ac72c9e3 /glanceclient/common/utils.py
parent0d22e821f9df4247e16a115f8b486d9bdd68eea1 (diff)
parent43621dc1ac626f7ce3322cee8b7908a93af20f26 (diff)
downloadpython-glanceclient-71d852836474f59f10a7bb9883f6dcecc56e5675.tar.gz
Merge "Close iterables at the end of iteration"
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r--glanceclient/common/utils.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index 9016860..7410b3b 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -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)