Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ Add compatibility with the next version of AnyIO #1936

Merged
merged 1 commit into from Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions starlette/testclient.py
Expand Up @@ -12,6 +12,7 @@
from urllib.parse import unquote, urljoin

import anyio
import anyio.from_thread
import httpx
from anyio.streams.stapled import StapledObjectStream

Expand Down Expand Up @@ -398,7 +399,9 @@ def _portal_factory(self) -> typing.Generator[anyio.abc.BlockingPortal, None, No
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(
Expand Down Expand Up @@ -714,7 +717,7 @@ def websocket_connect(
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
Expand Down