From 818761a95e7701d9ca6c27c8f288b54312043dcc Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 25 May 2011 17:15:31 +0100 Subject: Make enqueue_requests increment counter. --- bgproc.py | 1 + bgproc_tests.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/bgproc.py b/bgproc.py index 10dd2f4..4c3ead8 100644 --- a/bgproc.py +++ b/bgproc.py @@ -23,6 +23,7 @@ class BackgroundProcessing(object): def enqueue_request(self, request): '''Put a request into queue, to be processed by workers whenever.''' + self.pending_requests += 1 def close_requests(self): '''Signal workers that they can retire. diff --git a/bgproc_tests.py b/bgproc_tests.py index 17bc4fc..9709636 100644 --- a/bgproc_tests.py +++ b/bgproc_tests.py @@ -41,3 +41,7 @@ class BackgroundProcessingTests(unittest.TestCase): def test_iterates_to_empty_list_initially(self): self.assertEqual(list(self.bg), []) + def test_enqueue_increments_pending_requests(self): + self.bg.enqueue_request(0) + self.assertEqual(self.bg.pending_requests, 1) + -- cgit v1.2.1