コード例 #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),
        )
コード例 #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),
        )
コード例 #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)
コード例 #4
0
ファイル: log.py プロジェクト: Pehat/aiomisc
class AsyncMemoryHandler(logging.handlers.MemoryHandler):
    flush_async = threaded(logging.handlers.MemoryHandler.flush)