diff options
| author | Ryan Williams <breath@alum.mit.edu> | 2011-06-08 23:47:26 -0700 |
|---|---|---|
| committer | Ryan Williams <breath@alum.mit.edu> | 2011-06-08 23:47:26 -0700 |
| commit | f5e5b2bda7b442f0262ee1084deefcc5a1cc0694 (patch) | |
| tree | f4c2086f3d85a512e719de09c529ef35a9056d25 /tests | |
| parent | af21465a8b711359810d6a79c96a54f4a3a9218f (diff) | |
| download | eventlet-f5e5b2bda7b442f0262ee1084deefcc5a1cc0694.tar.gz | |
Better accounting of current_size in pools.Pool, thanks to Brett Hoerner for reporting #91.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/pools_test.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/pools_test.py b/tests/pools_test.py index e0c6cd6..77a8d04 100644 --- a/tests/pools_test.py +++ b/tests/pools_test.py @@ -137,6 +137,26 @@ class TestIntPool(TestCase): # resize larger and assert that there are more free items pool.resize(2) self.assertEquals(pool.free(), 2) + + def test_create_contention(self): + creates = [0] + def sleep_create(): + creates[0] += 1 + eventlet.sleep() + return "slept" + + p = pools.Pool(max_size=4, create=sleep_create) + + def do_get(): + x = p.get() + self.assertEquals(x, "slept") + p.put(x) + + gp = eventlet.GreenPool() + for i in xrange(100): + gp.spawn_n(do_get) + gp.waitall() + self.assertEquals(creates[0], 4) class TestAbstract(TestCase): |
