diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-06-09 11:28:37 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-06-09 11:28:37 +0200 |
commit | f2c8d26d3b25b864ad48e6de018757266b59f708 (patch) | |
tree | 4c455469b09e049ff8e29e6166bc2118356dc9cd /test/git/async/test_pool.py | |
parent | 15941ca090a2c3c987324fc911bbc6f89e941c47 (diff) | |
download | gitpython-f2c8d26d3b25b864ad48e6de018757266b59f708.tar.gz |
thread: fixed initialization problem if an empty iterable was handed in
queue: Queue now derives from deque directly, which safes one dict lookup as the queue does not need to be accessed through self anymore
pool test improved to better verify threads are started correctly
Diffstat (limited to 'test/git/async/test_pool.py')
-rw-r--r-- | test/git/async/test_pool.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/test/git/async/test_pool.py b/test/git/async/test_pool.py index ac8f1244..d38cbebd 100644 --- a/test/git/async/test_pool.py +++ b/test/git/async/test_pool.py @@ -253,13 +253,22 @@ class TestThreadPool(TestBase): assert p.size() == 0 # increase and decrease the size + num_threads = len(threading.enumerate()) for i in range(self.max_threads): p.set_size(i) assert p.size() == i + assert len(threading.enumerate()) == num_threads + i + for i in range(self.max_threads, -1, -1): p.set_size(i) assert p.size() == i - + + assert p.size() == 0 + # threads should be killed already, but we let them a tiny amount of time + # just to be sure + time.sleep(0.05) + assert len(threading.enumerate()) == num_threads + # SINGLE TASK SERIAL SYNC MODE ############################## # put a few unrelated tasks that we forget about @@ -268,7 +277,6 @@ class TestThreadPool(TestBase): assert p.num_tasks() == 2 ## SINGLE TASK ################# - assert p.size() == 0 self._assert_single_task(p, False) assert p.num_tasks() == 2 del(urc1) @@ -281,11 +289,12 @@ class TestThreadPool(TestBase): self._assert_async_dependent_tasks(p) - # SINGLE TASK THREADED SYNC MODE + # SINGLE TASK THREADED ASYNC MODE ################################ # step one gear up - just one thread for now. - num_threads = len(threading.enumerate()) p.set_size(1) + assert p.size() == 1 + print len(threading.enumerate()), num_threads assert len(threading.enumerate()) == num_threads + 1 # deleting the pool stops its threads - just to be sure ;) # Its not synchronized, hence we wait a moment |