From 4e6bece08aea01859a232e99a1e1ad8cc1eb7d36 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 9 Jun 2010 14:01:51 +0200 Subject: HSCondition: Fixed terrible bug which it inherited from its default python Condition implementation, related to the notify method not being treadsafe. Although I was aware of it, I missed the first check which tests for the size - the result could be incorrect if the whole method wasn't locked. Testing runs stable now, allowing to move on \! --- test/git/async/test_pool.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test/git/async/test_pool.py') diff --git a/test/git/async/test_pool.py b/test/git/async/test_pool.py index dacbf0be..cccafddc 100644 --- a/test/git/async/test_pool.py +++ b/test/git/async/test_pool.py @@ -98,7 +98,8 @@ class TestThreadPool(TestBase): items = rc.read() assert len(items) == ni task._assert(1, ni) - assert items[0] == 0 and items[-1] == ni-1 + if not async: + assert items[0] == 0 and items[-1] == ni-1 # as the task is done, it should have been removed - we have read everything assert task.is_done() @@ -152,8 +153,14 @@ class TestThreadPool(TestBase): assert p.num_tasks() == null_tasks task._assert(2, ni) # two chunks, ni calls - # its already done, gives us no more + # its already done, gives us no more, its still okay to use it though + # as a task doesn't have to be in the graph to allow reading its produced + # items print "read(0) on closed" + # it can happen that a thread closes the channel just a tiny fraction of time + # after we check this, so the test fails, although it is nearly closed. + # When we start reading, we should wake up once it sends its signal + # assert task.is_closed() assert len(rc.read()) == 0 # test chunking @@ -231,12 +238,18 @@ class TestThreadPool(TestBase): rc = p.add_task(task) print "read(0) with failure" assert len(rc.read()) == 0 # failure on first item + print >> sys.stderr, "done with everything" + assert isinstance(task.error(), AssertionError) assert task.is_done() # on error, its marked done as well del(rc) assert p.num_tasks() == null_tasks + # test failure after ni / 2 items + # This makes sure it correctly closes the channel on failure to prevent blocking + + def _assert_async_dependent_tasks(self, p): # includes failure in center task, 'recursive' orphan cleanup -- cgit v1.2.1