@@ -0,0 +1,2850 @@
+import sys%0Afrom eventlet import coropool, coros, api%0Afrom greentest import LimitedTestCase%0Afrom unittest import main%0A%0Aclass TestCoroutinePool(LimitedTestCase):%0A    klass = coropool.Pool%0A%0A    def test_execute_async(self):%0A        done = coros.event()%0A        def some_work():%0A            done.send()%0A        pool = self.klass(0, 2)%0A        pool.execute_async(some_work)%0A        done.wait()%0A%0A    def test_execute(self):%0A        value = 'return value'%0A        def some_work():%0A            return value%0A        pool = self.klass(0, 2)%0A        worker = pool.execute(some_work)%0A        self.assertEqual(value, worker.wait())%0A%0A    def test_multiple_coros(self):%0A        evt = coros.event()%0A        results = %5B%5D%0A        def producer():%0A            results.append('prod')%0A            evt.send()%0A%0A        def consumer():%0A            results.append('cons1')%0A            evt.wait()%0A            results.append('cons2')%0A%0A        pool = self.klass(0, 2)%0A        done = pool.execute(consumer)%0A        pool.execute_async(producer)%0A        done.wait()%0A        self.assertEquals(%5B'cons1', 'prod', 'cons2'%5D, results)%0A%0A    def test_reentrant(self):%0A        pool = self.klass(0,1)%0A        def reenter():%0A            waiter = pool.execute(lambda a: a, 'reenter')%0A            self.assertEqual('reenter', waiter.wait())%0A%0A        outer_waiter = pool.execute(reenter)%0A        outer_waiter.wait()%0A%0A        evt = coros.event()%0A        def reenter_async():%0A            pool.execute_async(lambda a: a, 'reenter')%0A            evt.send('done')%0A%0A        pool.execute_async(reenter_async)%0A        evt.wait()%0A%0A#     def test_track_events(self):%0A#         pool = self.klass(track_events=True)%0A#         for x in range(6):%0A#             pool.execute(lambda n: n, x)%0A#         for y in range(6):%0A#             pool.wait()%0A# %0A#     def test_track_slow_event(self):%0A#         pool = self.klass(track_events=True)%0A#         def slow():%0A#             api.sleep(0.1)%0A#             return 'ok'%0A#         pool.execute(slow)%0A#         self.assertEquals(pool.wait(), 'ok')%0A%0Aclass PoolBasicTests(LimitedTestCase):%0A    klass = coropool.Pool%0A%0A    def test_execute_async(self):%0A        p = self.klass(max_size=2)%0A        r = %5B%5D%0A        def foo(a):%0A            r.append(a)%0A        evt = p.execute(foo, 1)%0A        evt.wait()%0A        assert r == %5B1%5D, r%0A%0A        #Once the pool is exhausted, calling an execute forces a yield.%0A%0A        p.execute_async(foo, 2)%0A        assert r == %5B1%5D, r%0A        assert 0 == p.free()%0A        p.execute_async(foo, 3)%0A        assert r == %5B1, 2%5D, r%0A        assert 0 == p.free()%0A        p.execute_async(foo, 4)%0A        assert r == %5B1,2,3%5D, r%0A        api.sleep(0)%0A        assert r == %5B1,2,3,4%5D, r%0A%0A    def test_execute(self):%0A        p = self.klass()%0A        evt = p.execute(lambda a: ('foo', a), 1)%0A        assert evt.wait() == ('foo', 1)%0A%0A%0Aif __name__=='__main__':%0A    main()%0A%0A

add test for coropool