Skip to content

Commit

Permalink
Prefixed backend module names with an underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed May 12, 2019
1 parent aa5b388 commit 51cb13f
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions anyio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run(func: Callable[..., Coroutine[Any, Any, T_Retval]], *args,
raise RuntimeError('Already running {} in this thread'.format(asynclib_name))

try:
asynclib = import_module('{}._backends.{}'.format(__name__, backend))
asynclib = import_module('{}._backends._{}'.format(__name__, backend))
except ImportError as exc:
raise LookupError('No such backend: {}'.format(backend)) from exc

Expand All @@ -71,7 +71,7 @@ def run(func: Callable[..., Coroutine[Any, Any, T_Retval]], *args,

@contextmanager
def claim_worker_thread(backend) -> typing.Generator[Any, None, None]:
module = sys.modules['anyio._backends.' + backend]
module = sys.modules['anyio._backends._' + backend]
_local.current_async_module = module
token = sniffio.current_async_library_cvar.set(backend)
try:
Expand All @@ -83,7 +83,7 @@ def claim_worker_thread(backend) -> typing.Generator[Any, None, None]:

def _get_asynclib():
asynclib_name = sniffio.current_async_library()
modulename = 'anyio._backends.' + asynclib_name
modulename = 'anyio._backends._' + asynclib_name
try:
return sys.modules[modulename]
except KeyError:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This library adheres to `Semantic Versioning <http://semver.org/>`_.

- Fixed pathlib2_ compatibility with ``anyio.aopen()``
- Fixed timeouts not propagating from nested scopes on asyncio and curio (PR by Matthias Urlichs)
- Prefixed backend module names with an underscore to better indicate privateness

.. _pathlib2: https://pypi.org/project/pathlib2/

Expand Down
4 changes: 2 additions & 2 deletions tests/test_taskgroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from anyio import (
create_task_group, sleep, move_on_after, fail_after, open_cancel_scope, wait_all_tasks_blocked,
current_effective_deadline, current_time, get_cancelled_exc_class)
from anyio._backends import asyncio
from anyio._backends import _asyncio
from anyio.exceptions import ExceptionGroup


Expand Down Expand Up @@ -42,7 +42,7 @@ async def async_add(value):


@pytest.mark.parametrize('run_func, as_coro_obj', [
(asyncio.native_run, True),
(_asyncio.native_run, True),
(curio.run, False),
(trio.run, False)
], ids=['asyncio', 'curio', 'trio'])
Expand Down

0 comments on commit 51cb13f

Please sign in to comment.