Skip to content

Commit e86d76d

Browse files
fast_acquire
1 parent 711292e commit e86d76d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

httpcore/_synchronization.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import threading
23
from types import TracebackType
34
from typing import Optional, Type
@@ -64,7 +65,7 @@ def setup(self) -> None:
6465
if self._backend == "trio":
6566
self._trio_lock = trio.Lock()
6667
elif self._backend == "asyncio":
67-
self._anyio_lock = anyio.Lock()
68+
self._anyio_lock = anyio.Lock(fast_acquire=True)
6869

6970
async def __aenter__(self) -> "AsyncLock":
7071
if not self._backend:
@@ -167,7 +168,7 @@ def setup(self) -> None:
167168
)
168169
elif self._backend == "asyncio":
169170
self._anyio_semaphore = anyio.Semaphore(
170-
initial_value=self._bound, max_value=self._bound
171+
initial_value=self._bound, max_value=self._bound, fast_acquire=True
171172
)
172173

173174
async def acquire(self) -> None:

pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ trio = [
4444
"trio>=0.22.0,<0.26.0",
4545
]
4646
asyncio = [
47-
"anyio>=4.0,<5.0",
47+
"anyio @ {root:parent:uri}/anyio",
4848
]
4949

50+
[tool.hatch.metadata]
51+
allow-direct-references = true
52+
5053
[project.urls]
5154
Documentation = "https://www.encode.io/httpcore"
5255
Homepage = "https://www.encode.io/httpcore/"

0 commit comments

Comments
 (0)