def test_basic(self): loop = netius.get_loop(asyncio = False) self.assertNotEqual(loop, None) self.assertEqual(isinstance(loop, netius.Base), True) future = netius.build_future(compat = False, asyncio = False) self.assertNotEqual(future, None) self.assertEqual(isinstance(future, netius.Future), True) self.assertNotEqual(future._loop, None) self.assertEqual(isinstance(future._loop, netius.Base), True) previous = loop loop = netius.get_loop(_compat = True) self.assertNotEqual(loop, None) self.assertEqual(isinstance(loop, netius.BaseLoop), True) self.assertEqual(isinstance(loop, netius.CompatLoop), True) self.assertEqual(loop, previous._compat) self.assertEqual(loop._loop_ref(), previous) loop = netius.get_loop(asyncio = True) self.assertNotEqual(loop, None) if netius.is_asynclib(): self.assertEqual(isinstance(loop, netius.BaseLoop), True) self.assertEqual(isinstance(loop, netius.CompatLoop), True) else: self.assertEqual(isinstance(loop, netius.Base), True)
def test_basic(self): loop = netius.get_loop(asyncio=False) self.assertNotEqual(loop, None) self.assertEqual(isinstance(loop, netius.Base), True) future = netius.build_future(compat=False, asyncio=False) self.assertNotEqual(future, None) self.assertEqual(isinstance(future, netius.Future), True) self.assertNotEqual(future._loop, None) self.assertEqual(isinstance(future._loop, netius.Base), True) previous = loop loop = netius.get_loop(_compat=True) self.assertNotEqual(loop, None) self.assertEqual(isinstance(loop, netius.BaseLoop), True) self.assertEqual(isinstance(loop, netius.CompatLoop), True) self.assertEqual(loop, previous._compat) self.assertEqual(loop._loop_ref(), previous) loop = netius.get_loop(asyncio=True) self.assertNotEqual(loop, None) if netius.is_asynclib(): self.assertEqual(isinstance(loop, netius.BaseLoop), True) self.assertEqual(isinstance(loop, netius.CompatLoop), True) else: self.assertEqual(isinstance(loop, netius.Base), True)
async def await_forever(): print("Awaiting forever") future = netius.build_future() thread = threading.Thread(target=set, args=(future, ), kwargs=dict(raise_e=True)) thread.start() return await future
def await_forever(): print("Awaiting forever") future = netius.build_future() thread = threading.Thread(target=set, args=(future, ), kwargs=dict(raise_e=True)) thread.start() for value in future: yield value
def await_forever(): print("Awaiting forever") future = netius.build_future() thread = threading.Thread( target = set, args = (future,), kwargs = dict(raise_e = True) ) thread.start() for value in future: yield value
def await_forever(): print("Awaiting forever") future = netius.build_future() thread = threading.Thread( target = set, args = (future,), kwargs = dict(raise_e = True) ) thread.start() result = yield from future return result
def print_sum(x, y): future = netius.build_future() for value in compute(future, x, y): yield value result = future.result() print("%s + %s = %s" % (x, y, result))