async def test_await_only_no_greenlet(self):
        to_await = run1()
        with expect_raises_message(
                exc.MissingGreenlet,
                r"greenlet_spawn has not been called; can't call await_\(\) here.",
        ):
            await_only(to_await)

        # ensure no warning
        await greenlet_spawn(await_fallback, to_await)
Exemplo n.º 2
0
    def test_await_only_no_greenlet(self):
        to_await = run1()
        with expect_raises_message(
                exc.InvalidRequestError,
                r"greenlet_spawn has not been called; can't call await_\(\) here.",
        ):
            await_only(to_await)

        # ensure no warning
        await_fallback(to_await)
Exemplo n.º 3
0
        def inner(val):
            retval = await_only(async_inner(val))
            eq_(val, var.get())
            eq_(retval, val)

            # set the value in a sync function
            newval = val + concurrency
            var.set(newval)
            syncset = await_only(async_inner(newval))
            eq_(newval, var.get())
            eq_(syncset, newval)

            # set the value in an async function
            retval = val + 2 * concurrency
            await_only(async_set(retval))
            eq_(var.get(), retval)
            eq_(await_only(async_inner(retval)), retval)

            return retval
Exemplo n.º 4
0
 def go():
     await_only(inner_await())
Exemplo n.º 5
0
 async def inner_await():
     nonlocal to_await
     to_await = run1()
     await_only(to_await)
Exemplo n.º 6
0
 def go():
     await_only(run1())
     raise ValueError("sync error")
Exemplo n.º 7
0
def go(*fns):
    return sum(await_only(fn()) for fn in fns)
Exemplo n.º 8
0
 def inner(val):
     retval = await_only(async_inner(val))
     eq_(val, var.get())
     eq_(retval, val)
     return retval
 def sync_meth():
     try:
         await_only(async_meth_raise())
     except:
         cleanup.append(True)
         raise