concurrency.py
This file
Path
tests/concurrency.py
31 lines · 685 bytes · Python
Last changed by
Add trio concurrency backend (#276)Florimond Mancabefore adoption08355c6
History of this fileTake it
Parametrize tests with concurrency backend (#273)Florimond Mancabefore adoption3674058
lines 1–19why, one step back1"""2This module contains concurrency utilities that are only used in tests, thus not3required as part of the ConcurrencyBackend API.4"""56import asyncio7import functools89from httpx import AsyncioBackend101112@functools.singledispatch13async def sleep(backend, seconds: int):14 raise NotImplementedError # pragma: no cover151617@sleep.register(AsyncioBackend)18async def _sleep_asyncio(backend, seconds: int):19 await asyncio.sleep(seconds)Add trio concurrency backend (#276)Florimond Mancabefore adoption08355c6
lines 20–31why, one step back202122try:23 import trio24 from httpx.concurrency.trio import TrioBackend25except ImportError: # pragma: no cover26 pass27else:2829 @sleep.register(TrioBackend)30 async def _sleep_trio(backend, seconds: int):31 await trio.sleep(seconds)