mirror of https://github.com/encode/starlette.git
♻️ Add compatibility with the next version of AnyIO (#1936)
This commit is contained in:
parent
fbab16a2b1
commit
a45027209a
|
@ -12,6 +12,7 @@ from types import GeneratorType
|
|||
from urllib.parse import unquote, urljoin
|
||||
|
||||
import anyio
|
||||
import anyio.from_thread
|
||||
import httpx
|
||||
from anyio.streams.stapled import StapledObjectStream
|
||||
|
||||
|
@ -398,7 +399,9 @@ class TestClient(httpx.Client):
|
|||
if self.portal is not None:
|
||||
yield self.portal
|
||||
else:
|
||||
with anyio.start_blocking_portal(**self.async_backend) as portal:
|
||||
with anyio.from_thread.start_blocking_portal(
|
||||
**self.async_backend
|
||||
) as portal:
|
||||
yield portal
|
||||
|
||||
def _choose_redirect_arg(
|
||||
|
@ -714,7 +717,7 @@ class TestClient(httpx.Client):
|
|||
def __enter__(self) -> "TestClient":
|
||||
with contextlib.ExitStack() as stack:
|
||||
self.portal = portal = stack.enter_context(
|
||||
anyio.start_blocking_portal(**self.async_backend)
|
||||
anyio.from_thread.start_blocking_portal(**self.async_backend)
|
||||
)
|
||||
|
||||
@stack.callback
|
||||
|
|
Loading…
Reference in New Issue