async def test_error_other_loop(self): run = [False] def thread_go(q): def go(): eq_(q.get(block=False), 1) q.get(timeout=0.1) with expect_raises_message(RuntimeError, ".* to a different .*loop"): asyncio.run(greenlet_spawn(go)) run[0] = True q = queue.AsyncAdaptedQueue() def prime(): with expect_raises(queue.Empty): q.get(timeout=0.1) await greenlet_spawn(prime) q.put_nowait(1) t = threading.Thread(target=thread_go, args=[q]) t.start() t.join() is_true(run[0])
def test_lazy_init(self): run = [False] def thread_go(q): def go(): q.get(timeout=0.1) with expect_raises(queue.Empty): asyncio.run(greenlet_spawn(go)) run[0] = True t = threading.Thread(target=thread_go, args=[queue.AsyncAdaptedQueue()]) t.start() t.join() is_true(run[0])