File tree Expand file tree Collapse file tree 3 files changed +7
-58
lines changed Expand file tree Collapse file tree 3 files changed +7
-58
lines changed Original file line number Diff line number Diff line change 11import typing
22from typing import Optional
33
4- from .._synchronization import current_async_library
4+ from .._synchronization import current_async_backend
55from .base import SOCKET_OPTION , AsyncNetworkBackend , AsyncNetworkStream
66
77
88class AutoBackend (AsyncNetworkBackend ):
99 async def _init_backend (self ) -> None :
1010 if not (hasattr (self , "_backend" )):
11- backend = current_async_library ()
11+ backend = current_async_backend ()
1212 if backend == "trio" :
1313 from .trio import TrioBackend
1414
Original file line number Diff line number Diff line change 11import asyncio
2- import os
32import threading
43from types import TracebackType
54from typing import (
3130
3231
3332AsyncBackend = Literal ["asyncio" , "trio" ]
34- AsyncLibrary = Literal ["asyncio" , "trio" , "anyio" ]
3533
3634
3735def current_async_backend () -> AsyncBackend :
@@ -47,6 +45,11 @@ def current_async_backend() -> AsyncBackend:
4745 if environment not in ("asyncio" , "trio" ): # pragma: nocover
4846 raise RuntimeError ("Running under an unsupported async environment." )
4947
48+ if environment == "asyncio" and anyio is None : # pragma: nocover
49+ raise RuntimeError (
50+ "Running with asyncio requires installation of 'httpcore[asyncio]'."
51+ )
52+
5053 if environment == "trio" and trio is None : # pragma: nocover
5154 raise RuntimeError (
5255 "Running with trio requires installation of 'httpcore[trio]'."
@@ -55,18 +58,6 @@ def current_async_backend() -> AsyncBackend:
5558 return environment
5659
5760
58- def current_async_library () -> AsyncLibrary :
59- if current_async_backend () == "trio" :
60- return "trio"
61-
62- if anyio is not None :
63- anyio_env = os .environ .get ("HTTPCORE_PREFER_ANYIO" , "true" ).lower ()
64- if anyio_env in ("true" , "1" ):
65- return "anyio"
66-
67- return "asyncio"
68-
69-
7061class _LockProto (Protocol ):
7162 async def acquire (self ) -> Any : ...
7263 def release (self ) -> None : ...
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments