diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-05-25 17:20:39 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-05-25 17:20:39 +0100 |
commit | ea1b24550db19a119dac423f8aee21f690197ce8 (patch) | |
tree | 68e98a785bda6aa87ce18b6a16ec5dbb6d4d650b | |
parent | 675238bc117a77a3f30785f085846b70c593bcee (diff) | |
download | bgproc-ea1b24550db19a119dac423f8aee21f690197ce8.tar.gz |
Remove stuff after iterating over it.
-rw-r--r-- | bgproc.py | 3 | ||||
-rw-r--r-- | bgproc_tests.py | 1 |
2 files changed, 3 insertions, 1 deletions
@@ -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), []) |