Exemplo n.º 1
0
async def test_simple(event_loop, timer):
    sleep = threaded(time.sleep)

    with timer(1):
        await asyncio.gather(
            sleep(1),
            sleep(1),
            sleep(1),
            sleep(1),
        )
Exemplo n.º 2
0
async def test_threaded(executor: ThreadPoolExecutor, timer):
    assert executor

    sleep = threaded(time.sleep)

    with timer(1):
        await asyncio.gather(
            sleep(1),
            sleep(1),
            sleep(1),
            sleep(1),
            sleep(1),
        )
Exemplo n.º 3
0
async def test_cancel(executor: ThreadPoolExecutor, event_loop, timer):
    assert executor

    sleep = threaded(time.sleep)

    with timer(1, dispersion=2):
        tasks = [event_loop.create_task(sleep(1)) for _ in range(1000)]

        await asyncio.sleep(1)

        for task in tasks:
            task.cancel()

        executor.shutdown(wait=True)
Exemplo n.º 4
0
Arquivo: log.py Projeto: Pehat/aiomisc
class AsyncMemoryHandler(logging.handlers.MemoryHandler):
    flush_async = threaded(logging.handlers.MemoryHandler.flush)