summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-05-25 17:20:39 +0100
committerLars Wirzenius <liw@liw.fi>2011-05-25 17:20:39 +0100
commitea1b24550db19a119dac423f8aee21f690197ce8 (patch)
tree68e98a785bda6aa87ce18b6a16ec5dbb6d4d650b
parent675238bc117a77a3f30785f085846b70c593bcee (diff)
downloadbgproc-ea1b24550db19a119dac423f8aee21f690197ce8.tar.gz
Remove stuff after iterating over it.
-rw-r--r--bgproc.py3
-rw-r--r--bgproc_tests.py1
2 files changed, 3 insertions, 1 deletions
diff --git a/bgproc.py b/bgproc.py
index 949fb63..690880c 100644
--- a/bgproc.py
+++ b/bgproc.py
@@ -53,6 +53,7 @@ class BackgroundProcessing(object):
def __iter__(self):
'''Iterate over immediately available results.'''
- for result in self.results:
+ while self.results:
+ result = self.results.pop(0)
yield result
diff --git a/bgproc_tests.py b/bgproc_tests.py
index 885a223..dc6c79e 100644
--- a/bgproc_tests.py
+++ b/bgproc_tests.py
@@ -49,4 +49,5 @@ class BackgroundProcessingTests(unittest.TestCase):
self.bg.enqueue_request(0)
self.assertEqual(self.bg.wait_for_results(), True)
self.assertEqual(list(self.bg), [1])
+ self.assertEqual(list(self.bg), [])