diff --git a/httpcore/_synchronization.py b/httpcore/_synchronization.py index 9619a3983..328150040 100644 --- a/httpcore/_synchronization.py +++ b/httpcore/_synchronization.py @@ -64,7 +64,7 @@ def setup(self) -> None: if self._backend == "trio": self._trio_lock = trio.Lock() elif self._backend == "asyncio": - self._anyio_lock = anyio.Lock() + self._anyio_lock = anyio.Lock(fast_acquire=True) async def __aenter__(self) -> "AsyncLock": if not self._backend: @@ -167,7 +167,7 @@ def setup(self) -> None: ) elif self._backend == "asyncio": self._anyio_semaphore = anyio.Semaphore( - initial_value=self._bound, max_value=self._bound + initial_value=self._bound, max_value=self._bound, fast_acquire=True ) async def acquire(self) -> None: diff --git a/pyproject.toml b/pyproject.toml index 85c787402..a6727ae68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ trio = [ "trio>=0.22.0,<0.26.0", ] asyncio = [ - "anyio>=4.0,<5.0", + "anyio>=4.5.0,<5.0", ] [project.urls]