def test_sync_error(self): sync = gevent.spawn(self.return_error) async = gevent.spawn(self.return_async) ret = util.waitany([async, sync]) self.assertIs(ret, sync)
def test_async_error(self): async = gevent.spawn(self.return_error_async) never = gevent.spawn(self.never_return) ret = util.waitany([never, async]) self.assertIs(ret, async)
def test_async(self): """ Ensure that asynchronous greenlets are supported. """ async = gevent.spawn(self.return_async) never = gevent.spawn(self.never_return) ret = util.waitany([async, never]) self.assertIs(ret, async) self.assertEqual(ret.value, 4)
def test_sync(self): """ Ensure that synchronous greenlets are supported. """ sync = gevent.spawn(self.return_sync) # the context switch forces the above greenlet to run, prepping its # value gevent.sleep(0.0) self.assertTrue(sync.ready()) async = gevent.spawn(self.return_async) ret = util.waitany([async, sync]) self.assertIs(ret, sync) self.assertEqual(ret.value, 5)