Compare commits

..

No commits in common. "f067cf48a73bbf03072921664f6604017ad81e40" and "4c3c3e4b565637cd4ee9213501c0bf6a55a3b2dd" have entirely different histories.

7 changed files with 32 additions and 85 deletions

View File

@ -939,7 +939,6 @@ async def tell_little_bro(
def test_peer_spawns_and_cancels_service_subactor(
debug_mode: bool,
raise_client_error: str,
reg_addr: tuple[str, int],
):
# NOTE: this tests for the modden `mod wks open piker` bug
# discovered as part of implementing workspace ctx
@ -957,7 +956,6 @@ def test_peer_spawns_and_cancels_service_subactor(
async with tractor.open_nursery(
# NOTE: to halt the peer tasks on ctxc, uncomment this.
debug_mode=debug_mode,
registry_addrs=[reg_addr],
) as an:
server: Portal = await an.start_actor(
(server_name := 'spawn_server'),

View File

@ -1485,11 +1485,7 @@ class Context:
TODO: implement this using `outcome.Outcome` types?
'''
return (
self.maybe_error
or
self._result
)
return self.maybe_error or self._result
# @property
def repr_outcome(
@ -1524,28 +1520,16 @@ class Context:
#
# just the type name for now to avoid long lines
# when tons of cancels..
return (
str(type(merr).__name__)
or
repr(merr)
)
return type(merr).__name__
# just the type name
# else: # but wen?
# return type(merr).__name__
# for all other errors show their regular output
return (
str(merr)
or
repr(merr)
)
return str(merr)
return (
str(self._result)
or
repr(self._result)
)
return str(self._result)
async def started(
self,

View File

@ -35,10 +35,7 @@ from ._portal import (
open_portal,
LocalPortal,
)
from ._state import (
current_actor,
_runtime_vars,
)
from ._state import current_actor, _runtime_vars
if TYPE_CHECKING:
@ -208,11 +205,7 @@ async def find_actor(
# every call since something may change it globally (eg.
# like in our discovery test suite)!
from . import _root
registry_addrs = (
_runtime_vars['_registry_addrs']
or
_root._default_lo_addrs
)
registry_addrs = _root._default_lo_addrs
maybe_portals: list[
AsyncContextManager[tuple[str, int]]

View File

@ -30,7 +30,7 @@ from typing import (
Any,
Callable,
AsyncGenerator,
# Type,
Type,
)
from functools import partial
from dataclasses import dataclass
@ -41,7 +41,8 @@ from async_generator import asynccontextmanager
from .trionics import maybe_open_nursery
from .devx import (
# _debug,
# acquire_debug_lock,
# pause,
maybe_wait_for_debugger,
)
from ._state import (
@ -672,7 +673,6 @@ class Portal:
# `Nursery.cancel_scope.cancel()`)
except ContextCancelled as ctxc:
scope_err = ctxc
ctx._local_error: BaseException = scope_err
ctxc_from_callee = ctxc
# XXX TODO XXX: FIX THIS debug_mode BUGGGG!!!
@ -684,7 +684,7 @@ class Portal:
# debugging the tractor-runtime itself using it's
# own `.devx.` tooling!
#
# await _debug.pause()
# await pause()
# CASE 2: context was cancelled by local task calling
# `.cancel()`, we don't raise and the exit block should
@ -745,20 +745,18 @@ class Portal:
) as caller_err:
scope_err = caller_err
ctx._local_error: BaseException = scope_err
# XXX: ALWAYS request the context to CANCEL ON any ERROR.
# NOTE: `Context.cancel()` is conversely NEVER CALLED in
# the `ContextCancelled` "self cancellation absorbed" case
# handled in the block above ^^^ !!
# await _debug.pause()
log.cancel(
'Context terminated due to\n\n'
f'.outcome => {ctx.repr_outcome()}\n'
f'{caller_err}\n'
)
if debug_mode():
# async with _debug.acquire_debug_lock(self.actor.uid):
# async with acquire_debug_lock(self.actor.uid):
# pass
# TODO: factor ^ into below for non-root cases?
was_acquired: bool = await maybe_wait_for_debugger(
@ -820,7 +818,6 @@ class Portal:
# this task didn't know until final teardown
# / value collection.
scope_err = berr
ctx._local_error: BaseException = scope_err
raise
# yes! this worx Bp
@ -930,10 +927,8 @@ class Portal:
# should be stored as the `Context._local_error` and
# used in determining `Context.cancelled_caught: bool`.
if scope_err is not None:
# sanity, tho can remove?
assert ctx._local_error is scope_err
# ctx._local_error: BaseException = scope_err
# etype: Type[BaseException] = type(scope_err)
ctx._local_error: BaseException = scope_err
etype: Type[BaseException] = type(scope_err)
# CASE 2
if (

View File

@ -811,10 +811,10 @@ class Actor:
name: str,
*,
enable_modules: list[str] = [],
uid: str|None = None,
loglevel: str|None = None,
registry_addrs: list[tuple[str, int]]|None = None,
spawn_method: str|None = None,
uid: str | None = None,
loglevel: str | None = None,
registry_addrs: list[tuple[str, int]] | None = None,
spawn_method: str | None = None,
# TODO: remove!
arbiter_addr: tuple[str, int] | None = None,
@ -896,7 +896,6 @@ class Actor:
self._reg_addrs: list[tuple[str, int]] = []
if registry_addrs:
self.reg_addrs: list[tuple[str, int]] = registry_addrs
_state._runtime_vars['_registry_addrs'] = registry_addrs
@property
def reg_addrs(self) -> list[tuple[str, int]]:

View File

@ -33,8 +33,7 @@ _last_actor_terminated: Actor|None = None
_runtime_vars: dict[str, Any] = {
'_debug_mode': False,
'_is_root': False,
'_root_mailbox': (None, None),
'_registry_addrs': [],
'_root_mailbox': (None, None)
}

View File

@ -216,14 +216,7 @@ def _run_asyncio_task(
try:
result = await coro
except BaseException as aio_err:
if isinstance(aio_err, CancelledError):
log.runtime(
'`asyncio` task was cancelled..\n'
)
else:
log.exception(
'`asyncio` task errored\n'
)
log.exception('asyncio task errored')
chan._aio_err = aio_err
raise
@ -278,22 +271,12 @@ def _run_asyncio_task(
except BaseException as terr:
task_err = terr
msg: str = (
'Infected `asyncio` task {etype_str}\n'
f'|_{task}\n'
)
if isinstance(terr, CancelledError):
log.cancel(
msg.format(etype_str='cancelled')
)
log.cancel(f'`asyncio` task cancelled: {task.get_name()}')
else:
log.exception(
msg.format(etype_str='cancelled')
)
log.exception(f'`asyncio` task: {task.get_name()} errored')
assert type(terr) is type(aio_err), (
'`asyncio` task error mismatch?!?'
)
assert type(terr) is type(aio_err), 'Asyncio task error mismatch?'
if aio_err is not None:
# XXX: uhh is this true?
@ -306,23 +289,19 @@ def _run_asyncio_task(
# We might want to change this in the future though.
from_aio.close()
if task_err is None:
assert aio_err
aio_err.with_traceback(aio_err.__traceback__)
# log.error(
# 'infected task errorred'
# )
if type(aio_err) is CancelledError:
log.cancel("infected task was cancelled")
# TODO: show that the cancellation originated
# from the ``trio`` side? right?
# elif type(aio_err) is CancelledError:
# log.cancel(
# 'infected task was cancelled'
# )
# if cancel_scope.cancelled:
# raise aio_err from err
elif task_err is None:
assert aio_err
aio_err.with_traceback(aio_err.__traceback__)
log.error('infected task errorred')
# XXX: alway cancel the scope on error
# in case the trio task is blocking
# on a checkpoint.