Drop now-deprecated deps on modern `trio`/Python

- `trio_typing` is nearly obsolete since `trio >= 0.23`
- `exceptiongroup` is built-in to python 3.11
- `async_generator` primitives have lived in `contextlib` for quite
  a while!
mv_to_new_trio_py3.11
Tyler Goodlet 2024-03-13 18:41:24 -04:00
parent e5cb39804c
commit 71de56b09a
19 changed files with 47 additions and 48 deletions

View File

@ -0,0 +1,9 @@
'''
Reproduce a bug where enabling debug mode for a sub-actor actually causes
a hang on teardown...
'''
import asyncio
import trio
import tractor

View File

@ -8,7 +8,10 @@ This uses no extra threads, fancy semaphores or futures; all we need
is ``tractor``'s channels.
"""
from contextlib import asynccontextmanager
from contextlib import (
asynccontextmanager as acm,
aclosing,
)
from typing import Callable
import itertools
import math
@ -16,7 +19,6 @@ import time
import tractor
import trio
from async_generator import aclosing
PRIMES = [
@ -44,7 +46,7 @@ async def is_prime(n):
return True
@asynccontextmanager
@acm
async def worker_pool(workers=4):
"""Though it's a trivial special case for ``tractor``, the well
known "worker pool" seems to be the defacto "but, I want this

View File

@ -13,7 +13,7 @@ async def simple_rpc(
'''
# signal to parent that we're up much like
# ``trio_typing.TaskStatus.started()``
# ``trio.TaskStatus.started()``
await ctx.started(data + 1)
async with ctx.open_stream() as stream:

View File

@ -47,9 +47,10 @@ setup(
# proper range spec:
# https://packaging.python.org/en/latest/discussions/install-requires-vs-requirements/#id5
'trio >= 0.24',
'async_generator',
'trio_typing',
'exceptiongroup',
# 'async_generator', # in stdlib mostly!
# 'trio_typing', # trio==0.23.0 has type hints!
# 'exceptiongroup', # in stdlib as of 3.11!
# tooling
'stackscope',

View File

@ -8,10 +8,6 @@ import platform
import time
from itertools import repeat
from exceptiongroup import (
BaseExceptionGroup,
ExceptionGroup,
)
import pytest
import trio
import tractor

View File

@ -6,13 +6,15 @@ sub-sub-actor daemons.
'''
from typing import Optional
import asyncio
from contextlib import asynccontextmanager as acm
from contextlib import (
asynccontextmanager as acm,
aclosing,
)
import pytest
import trio
import tractor
from tractor import RemoteActorError
from async_generator import aclosing
async def aio_streamer(

View File

@ -8,7 +8,6 @@ import builtins
import itertools
import importlib
from exceptiongroup import BaseExceptionGroup
import pytest
import trio
import tractor

View File

@ -64,7 +64,8 @@ async def test_lifetime_stack_wipes_tmpfile(
except (
tractor.RemoteActorError,
tractor.BaseExceptionGroup,
# tractor.BaseExceptionGroup,
BaseExceptionGroup,
):
pass

View File

@ -5,7 +5,7 @@ want to see changed.
'''
import pytest
import trio
from trio_typing import TaskStatus
from trio import TaskStatus
@pytest.mark.parametrize(

View File

@ -18,8 +18,6 @@
tractor: structured concurrent ``trio``-"actors".
"""
from exceptiongroup import BaseExceptionGroup as BaseExceptionGroup
from ._clustering import (
open_actor_cluster as open_actor_cluster,
)

View File

@ -30,11 +30,10 @@ from typing import (
import textwrap
import traceback
import exceptiongroup as eg
import trio
from ._state import current_actor
from .log import get_logger
from tractor._state import current_actor
from tractor.log import get_logger
if TYPE_CHECKING:
from ._context import Context
@ -373,7 +372,6 @@ def unpack_error(
for ns in [
builtins,
_this_mod,
eg,
trio,
]:
if suberror_type := getattr(
@ -396,12 +394,13 @@ def unpack_error(
def is_multi_cancelled(exc: BaseException) -> bool:
'''
Predicate to determine if a possible ``eg.BaseExceptionGroup`` contains
Predicate to determine if a possible ``BaseExceptionGroup`` contains
only ``trio.Cancelled`` sub-exceptions (and is likely the result of
cancelling a collection of subtasks.
'''
if isinstance(exc, eg.BaseExceptionGroup):
# if isinstance(exc, eg.BaseExceptionGroup):
if isinstance(exc, BaseExceptionGroup):
return exc.subgroup(
lambda exc: isinstance(exc, trio.Cancelled)
) is not None

View File

@ -28,12 +28,13 @@ import os
import warnings
from exceptiongroup import BaseExceptionGroup
import trio
from ._runtime import (
Actor,
Arbiter,
# TODO: rename and make a non-actor subtype?
# Arbiter as Registry,
async_main,
)
from .devx import _debug

View File

@ -21,6 +21,7 @@ Remote (task) Procedure Call (scheduling) with SC transitive semantics.
from __future__ import annotations
from contextlib import (
asynccontextmanager as acm,
aclosing,
)
from functools import partial
import inspect
@ -34,17 +35,12 @@ from typing import (
)
import warnings
from async_generator import aclosing
from exceptiongroup import BaseExceptionGroup
import trio
from trio import (
CancelScope,
Nursery,
TaskStatus,
)
# from trio_typing import (
# TaskStatus,
# )
from .msg import NamespacePath
from ._ipc import Channel

View File

@ -61,8 +61,6 @@ import warnings
import trio
from trio import (
CancelScope,
)
from trio_typing import (
Nursery,
TaskStatus,
)

View File

@ -46,7 +46,7 @@ if _USE_POSIX:
try:
import numpy as np
from numpy.lib import recfunctions as rfn
import nptyping
# import nptyping
except ImportError:
pass

View File

@ -31,25 +31,24 @@ from typing import (
TYPE_CHECKING,
)
from exceptiongroup import BaseExceptionGroup
import trio
from trio_typing import TaskStatus
from trio import TaskStatus
from .devx import (
from tractor.devx import (
maybe_wait_for_debugger,
acquire_debug_lock,
)
from ._state import (
from tractor._state import (
current_actor,
is_main_process,
is_root_process,
debug_mode,
)
from .log import get_logger
from ._portal import Portal
from ._runtime import Actor
from ._entry import _mp_main
from ._exceptions import ActorFailure
from tractor.log import get_logger
from tractor._portal import Portal
from tractor._runtime import Actor
from tractor._entry import _mp_main
from tractor._exceptions import ActorFailure
if TYPE_CHECKING:

View File

@ -26,7 +26,6 @@ from typing import TYPE_CHECKING
import typing
import warnings
from exceptiongroup import BaseExceptionGroup
import trio
from .devx._debug import maybe_wait_for_debugger

View File

@ -31,7 +31,7 @@ from typing import (
Callable,
)
from functools import partial
from async_generator import aclosing
from contextlib import aclosing
import trio
import wrapt

View File

@ -33,10 +33,9 @@ from typing import (
)
import trio
from trio_typing import TaskStatus
from .._state import current_actor
from ..log import get_logger
from tractor._state import current_actor
from tractor.log import get_logger
log = get_logger(__name__)
@ -184,7 +183,7 @@ class _Cache:
cls,
mng,
ctx_key: tuple,
task_status: TaskStatus[T] = trio.TASK_STATUS_IGNORED,
task_status: trio.TaskStatus[T] = trio.TASK_STATUS_IGNORED,
) -> None:
async with mng as value: