Skip to content

Commit

Permalink
Low-level API: asyncio backend is now a private implementation (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia authored Jun 28, 2024
1 parent dfac978 commit 83273be
Show file tree
Hide file tree
Showing 39 changed files with 139 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@

from __future__ import annotations

__all__ = ["AsyncIOBackend"] # type: list[str]

from .backend import AsyncIOBackend
__all__ = [] # type: list[str]
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from collections.abc import Iterable, Sequence
from typing import Any, cast

from .. import _utils
from .... import _utils


async def ensure_resolved(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import types
from collections.abc import Callable

from .. import _utils
from .... import _utils
from .tasks import TaskUtils


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
from collections.abc import Awaitable, Callable, Coroutine, Mapping, Sequence
from typing import Any, NoReturn, ParamSpec, TypeVar, TypeVarTuple

from .. import _utils
from ..api_async.backend import _sniffio_helpers
from ..api_async.backend.abc import AsyncBackend as AbstractAsyncBackend, ILock, TaskInfo
from ..constants import HAPPY_EYEBALLS_DELAY as _DEFAULT_HAPPY_EYEBALLS_DELAY
from .... import _utils
from ....constants import HAPPY_EYEBALLS_DELAY as _DEFAULT_HAPPY_EYEBALLS_DELAY
from .. import _sniffio_helpers
from ..abc import AsyncBackend as AbstractAsyncBackend, ILock, TaskInfo
from ._asyncio_utils import (
create_connection,
create_datagram_connection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import warnings
from typing import Any, final

from ... import _utils
from ..... import _utils
from .._flow_control import WriteFlowControl


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
from collections.abc import Callable, Coroutine, Mapping
from typing import Any, NoReturn, final

from ... import _utils, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend, TaskGroup
from ...api_async.transports import abc as transports
from ..... import _utils, socket as socket_tools
from ....transports import abc as transports
from ...abc import AsyncBackend, TaskGroup
from .._flow_control import WriteFlowControl
from .endpoint import _monkeypatch_transport

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
from collections.abc import Callable, Mapping
from typing import Any, final

from ... import _utils, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend
from ...api_async.transports.abc import AsyncDatagramTransport
from ..... import _utils, socket as socket_tools
from ....transports.abc import AsyncDatagramTransport
from ...abc import AsyncBackend
from .endpoint import DatagramEndpoint


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
from collections.abc import Callable, Coroutine, Mapping
from typing import Any, Generic, NoReturn, TypeVar, final

from ... import _utils, constants, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend, CancelScope, TaskGroup
from ...api_async.transports.abc import AsyncListener, AsyncStreamTransport
from ..... import _utils, constants, socket as socket_tools
from ....transports.abc import AsyncListener, AsyncStreamTransport
from ...abc import AsyncBackend, CancelScope, TaskGroup
from ..tasks import TaskUtils
from .socket import AsyncioTransportStreamSocketAdapter, StreamReaderBufferedProtocol

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
from types import TracebackType
from typing import TYPE_CHECKING, Any, final

from ....exceptions import UnsupportedOperation
from ... import _utils, socket as socket_tools
from ...api_async.backend.abc import AsyncBackend
from ...api_async.transports.abc import AsyncStreamTransport
from ......exceptions import UnsupportedOperation
from ..... import _utils, socket as socket_tools
from ....transports.abc import AsyncStreamTransport
from ...abc import AsyncBackend
from .._asyncio_utils import add_flowcontrol_defaults
from .._flow_control import WriteFlowControl

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@
from typing import Any, ClassVar, NamedTuple, Self, TypeVar, TypeVarTuple, cast, final
from weakref import WeakKeyDictionary

from .. import _utils
from .._final import runtime_final_class
from ..api_async.backend.abc import (
CancelScope as AbstractCancelScope,
Task as AbstractTask,
TaskGroup as AbstractTaskGroup,
TaskInfo,
)
from .... import _utils
from ...._final import runtime_final_class
from ..abc import CancelScope as AbstractCancelScope, Task as AbstractTask, TaskGroup as AbstractTaskGroup, TaskInfo

_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
from types import TracebackType
from typing import ParamSpec, Self, TypeVar, final

from .. import _lock, _utils
from .._final import runtime_final_class
from ..api_async.backend import _sniffio_helpers
from ..api_async.backend.abc import ThreadsPortal as AbstractThreadsPortal
from .... import _lock, _utils
from ...._final import runtime_final_class
from .. import _sniffio_helpers
from ..abc import ThreadsPortal as AbstractThreadsPortal
from .tasks import TaskUtils

_P = ParamSpec("_P")
Expand Down
2 changes: 1 addition & 1 deletion src/easynetwork/lowlevel/api_async/backend/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def ensure_backend(backend: AsyncBackend | BuiltinAsyncBackendLiteral | None) ->

match backend:
case "asyncio":
from ...std_asyncio.backend import AsyncIOBackend
from ._asyncio.backend import AsyncIOBackend

return AsyncIOBackend()
case AsyncBackend():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from contextlib import ExitStack
from typing import TYPE_CHECKING, Any, Literal, Required, TypedDict

from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.api_async.backend.abc import TaskInfo
from easynetwork.lowlevel.std_asyncio.backend import AsyncIOBackend

import pytest

Expand Down Expand Up @@ -1226,7 +1226,7 @@ def cancel_shielded_coroutine(
case "run_in_thread":
return lambda: backend.run_in_thread(time.sleep, 0.1)
case "cancel_shielded_wait_asyncio_futures":
from easynetwork.lowlevel.std_asyncio.tasks import TaskUtils
from easynetwork.lowlevel.api_async.backend._asyncio.tasks import TaskUtils

async def cancel_shielded_wait_asyncio_futures() -> None:
loop = asyncio.get_running_loop()
Expand Down
2 changes: 1 addition & 1 deletion tests/functional_test/test_async/test_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from collections.abc import AsyncIterator
from typing import Any

from easynetwork.lowlevel.api_async.backend._asyncio.backend import AsyncIOBackend
from easynetwork.lowlevel.futures import AsyncExecutor, unwrap_future
from easynetwork.lowlevel.std_asyncio.backend import AsyncIOBackend

import pytest
import pytest_asyncio
Expand Down
Loading

0 comments on commit 83273be

Please sign in to comment.