summaryrefslogtreecommitdiff
path: root/test/git/async/test_pool.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-09 14:01:51 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-09 14:01:51 +0200
commit4e6bece08aea01859a232e99a1e1ad8cc1eb7d36 (patch)
tree33a0ebf9c5510b191de219029c8cfedb9df97ab3 /test/git/async/test_pool.py
parenta988e6985849e4f6a561b4a5468d525c25ce74fe (diff)
downloadgitpython-4e6bece08aea01859a232e99a1e1ad8cc1eb7d36.tar.gz
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 \!
Diffstat (limited to 'test/git/async/test_pool.py')
-rw-r--r--test/git/async/test_pool.py17
1 files changed, 15 insertions, 2 deletions
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