Compare commits

..

No commits in common. "71de56b09a73dcaf14d5222f49bc68bedcfcb4c9" and "d28c7e17c650a356868eaf7f738965dfbd5afbc1" have entirely different histories.

19 changed files with 49 additions and 48 deletions

View File

@ -1,9 +0,0 @@
'''
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,10 +8,7 @@ This uses no extra threads, fancy semaphores or futures; all we need
is ``tractor``'s channels.
"""
from contextlib import (
asynccontextmanager as acm,
aclosing,
)
from contextlib import asynccontextmanager
from typing import Callable
import itertools
import math
@ -19,6 +16,7 @@ import time
import tractor
import trio
from async_generator import aclosing
PRIMES = [
@ -46,7 +44,7 @@ async def is_prime(n):
return True
@acm
@asynccontextmanager
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.TaskStatus.started()``
# ``trio_typing.TaskStatus.started()``
await ctx.started(data + 1)
async with ctx.open_stream() as stream:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,13 +28,12 @@ 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,7 +21,6 @@ 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
@ -35,12 +34,17 @@ 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,6 +61,8 @@ 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,24 +31,25 @@ from typing import (
TYPE_CHECKING,
)
from exceptiongroup import BaseExceptionGroup
import trio
from trio import TaskStatus
from trio_typing import TaskStatus
from tractor.devx import (
from .devx import (
maybe_wait_for_debugger,
acquire_debug_lock,
)
from tractor._state import (
from ._state import (
current_actor,
is_main_process,
is_root_process,
debug_mode,
)
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
from .log import get_logger
from ._portal import Portal
from ._runtime import Actor
from ._entry import _mp_main
from ._exceptions import ActorFailure
if TYPE_CHECKING:

View File

@ -26,6 +26,7 @@ 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 contextlib import aclosing
from async_generator import aclosing
import trio
import wrapt

View File

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