Skip to content

Commit 973cbdd

Browse files
Use AnyIO fast_acquire (#953)
Co-authored-by: Thomas Grainger <[email protected]>
1 parent 8b8ab18 commit 973cbdd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

httpcore/_synchronization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def setup(self) -> None:
6565
if self._backend == "trio":
6666
self._trio_lock = trio.Lock()
6767
elif self._backend == "asyncio":
68-
self._anyio_lock = anyio.Lock()
68+
self._anyio_lock = anyio.Lock(fast_acquire=True)
6969

7070
async def __aenter__(self) -> AsyncLock:
7171
if not self._backend:
@@ -168,7 +168,7 @@ def setup(self) -> None:
168168
)
169169
elif self._backend == "asyncio":
170170
self._anyio_semaphore = anyio.Semaphore(
171-
initial_value=self._bound, max_value=self._bound
171+
initial_value=self._bound, max_value=self._bound, fast_acquire=True
172172
)
173173

174174
async def acquire(self) -> None:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ trio = [
4444
"trio>=0.22.0,<1.0",
4545
]
4646
asyncio = [
47-
"anyio>=4.0,<5.0",
47+
"anyio>=4.5.0,<5.0",
4848
]
4949

5050
[project.urls]

0 commit comments

Comments
 (0)