Compare commits

..

No commits in common. "010d75248ea5cfbc3f5c4e3215fa63f002c131e7" and "b1018a13febf3f97aabc0168d70ab04afe498e6e" have entirely different histories.

2 changed files with 22 additions and 23 deletions

View File

@ -25,7 +25,7 @@ async def bp_then_error(
) -> None:
# sync with `trio`-side (caller) task
# sync with ``trio``-side (caller) task
to_trio.send_nowait('start')
# NOTE: what happens here inside the hook needs some refinement..
@ -33,7 +33,8 @@ async def bp_then_error(
# we set `Lock.local_task_in_debug = 'sync'`, we probably want
# some further, at least, meta-data about the task/actor in debug
# in terms of making it clear it's `asyncio` mucking about.
breakpoint() # asyncio-side
breakpoint()
# short checkpoint / delay
await asyncio.sleep(0.5) # asyncio-side
@ -57,6 +58,7 @@ async def trio_ctx(
# this will block until the ``asyncio`` task sends a "first"
# message, see first line in above func.
async with (
to_asyncio.open_channel_from(
bp_then_error,
# raise_after_bp=not bp_before_started,
@ -67,7 +69,7 @@ async def trio_ctx(
assert first == 'start'
if bp_before_started:
await tractor.pause() # trio-side
await tractor.pause()
await ctx.started(first) # trio-side
@ -109,7 +111,7 @@ async def main(
# pause in parent to ensure no cross-actor
# locking problems exist!
await tractor.pause() # trio-root
await tractor.pause()
if cancel_from_root:
await ctx.cancel()

View File

@ -103,16 +103,7 @@ class AsyncioTaskExited(Exception):
'''
class TrioCancelled(Exception):
'''
Trio cancelled translation (non-base) error
for use with the `to_asyncio` module
to be raised in the `asyncio.Task` to indicate
that the `trio` side raised `Cancelled` or an error.
'''
class TrioTaskExited(Exception):
class TrioTaskExited(AsyncioCancelled):
'''
The `trio`-side task exited without explicitly cancelling the
`asyncio.Task` peer.
@ -415,9 +406,6 @@ class RemoteActorError(Exception):
String-name of the (last hop's) boxed error type.
'''
# TODO, maybe support also serializing the
# `ExceptionGroup.exeptions: list[BaseException]` set under
# certain conditions?
bt: Type[BaseException] = self.boxed_type
if bt:
return str(bt.__name__)
@ -833,11 +821,8 @@ class MsgTypeError(
'''
if (
(_bad_msg := self.msgdata.get('_bad_msg'))
and (
isinstance(_bad_msg, PayloadMsg)
or
isinstance(_bad_msg, msgtypes.Start)
)
and
isinstance(_bad_msg, PayloadMsg)
):
return _bad_msg
@ -1030,6 +1015,18 @@ class MessagingError(Exception):
'''
class AsyncioCancelled(Exception):
'''
Asyncio cancelled translation (non-base) error
for use with the ``to_asyncio`` module
to be raised in the ``trio`` side task
NOTE: this should NOT inherit from `asyncio.CancelledError` or
tests should break!
'''
def pack_error(
exc: BaseException|RemoteActorError,
@ -1209,7 +1206,7 @@ def is_multi_cancelled(
trio.Cancelled in ignore_nested
# XXX always count-in `trio`'s native signal
):
ignore_nested.update({trio.Cancelled})
ignore_nested |= {trio.Cancelled}
if isinstance(exc, BaseExceptionGroup):
matched_exc: BaseExceptionGroup|None = exc.subgroup(