Пример #1
0
async def run(name: str):
    logger.info("starting runner", name=name)
    bind(runner=name)

    for _ in range(10):
        wait = random.randrange(1, 15) / 10
        logger.info("waiting for next message", now=time.time(), wait=wait)
        await nested()
        await asyncio.sleep(wait)

    logger.info("unbinding runner name")
    unbind("runner")
    logger.info("done")
Пример #2
0
def bench_async_context(loops, logger):
    # use fast local vars
    m = MSG_FORMAT_LONG_SIMPLE
    args = LONG_ARGS_SIMPLE
    range_loops = range(loops)
    t0 = pyperf.perf_counter()

    logctx.bind(testing=True, value="foo")

    for _ in range_loops:
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)
        logger.warning(m, *args)

    logctx.clear()

    return pyperf.perf_counter() - t0
Пример #3
0
 async def coro():
     contextvars.bind(a=5, b="foo")
     contextvars.bind(b="bar", c=False)
     contextvars.merge(event)
Пример #4
0
 async def coro():
     contextvars.bind(a=5, b="foo", c=False)
     contextvars.clear()
     contextvars.merge(event)
Пример #5
0
 async def coro():
     contextvars.bind(a=5, c=True)
     contextvars.merge(event)
Пример #6
0
 async def coro():
     contextvars.bind(a=5)
     contextvars.unbind("a")
     contextvars.merge(event)
Пример #7
0
 async def coro():
     contextvars.bind(a=5, b="foo", c=False)
     contextvars.unbind("b")
     contextvars.merge(event)
Пример #8
0
 async def coro3():
     contextvars.bind(c=False)
     contextvars.merge(event)
Пример #9
0
 async def coro2():
     contextvars.bind(b="bar")
     await coro3()
Пример #10
0
 async def coro1():
     contextvars.bind(a=5)
     await coro2()