summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2011-05-25 17:22:50 +0100
committerLars Wirzenius <liw@liw.fi>2011-05-25 17:22:50 +0100
commit9ac6d3e09a4b98ea8acc3a6e4d00aaa9ce3d2962 (patch)
treee794ecd9c98e4d3a213d1c3075c2c7df2618b7c9
parentea1b24550db19a119dac423f8aee21f690197ce8 (diff)
downloadbgproc-9ac6d3e09a4b98ea8acc3a6e4d00aaa9ce3d2962.tar.gz
Fix wait to remove requests from queue.
-rw-r--r--bgproc.py5
-rw-r--r--bgproc_tests.py1
2 files changed, 5 insertions, 1 deletions
diff --git a/bgproc.py b/bgproc.py
index 690880c..940f0ae 100644
--- a/bgproc.py
+++ b/bgproc.py
@@ -47,7 +47,10 @@ class BackgroundProcessing(object):
because all requests have been processed.
'''
- for request in self.requests:
+
+ while self.requests:
+ request = self.requests.pop(0)
+ self.pending_requests -= 1
self.results.append(self.func(request))
return len(self.results) > 0
diff --git a/bgproc_tests.py b/bgproc_tests.py
index dc6c79e..74f1ff1 100644
--- a/bgproc_tests.py
+++ b/bgproc_tests.py
@@ -50,4 +50,5 @@ class BackgroundProcessingTests(unittest.TestCase):
self.assertEqual(self.bg.wait_for_results(), True)
self.assertEqual(list(self.bg), [1])
self.assertEqual(list(self.bg), [])
+ self.assertEqual(self.bg.pending_requests, 0)