Compare commits
3 Commits
b1018a13fe
...
010d75248e
Author | SHA1 | Date |
---|---|---|
|
010d75248e | |
|
47ec7e7a49 | |
|
a66caa2397 |
|
@ -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,8 +33,7 @@ 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()
|
||||
|
||||
breakpoint() # asyncio-side
|
||||
|
||||
# short checkpoint / delay
|
||||
await asyncio.sleep(0.5) # asyncio-side
|
||||
|
@ -58,7 +57,6 @@ 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,
|
||||
|
@ -69,7 +67,7 @@ async def trio_ctx(
|
|||
assert first == 'start'
|
||||
|
||||
if bp_before_started:
|
||||
await tractor.pause()
|
||||
await tractor.pause() # trio-side
|
||||
|
||||
await ctx.started(first) # trio-side
|
||||
|
||||
|
@ -111,7 +109,7 @@ async def main(
|
|||
|
||||
# pause in parent to ensure no cross-actor
|
||||
# locking problems exist!
|
||||
await tractor.pause()
|
||||
await tractor.pause() # trio-root
|
||||
|
||||
if cancel_from_root:
|
||||
await ctx.cancel()
|
||||
|
|
|
@ -103,7 +103,16 @@ class AsyncioTaskExited(Exception):
|
|||
|
||||
'''
|
||||
|
||||
class TrioTaskExited(AsyncioCancelled):
|
||||
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):
|
||||
'''
|
||||
The `trio`-side task exited without explicitly cancelling the
|
||||
`asyncio.Task` peer.
|
||||
|
@ -406,6 +415,9 @@ 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__)
|
||||
|
@ -821,8 +833,11 @@ class MsgTypeError(
|
|||
'''
|
||||
if (
|
||||
(_bad_msg := self.msgdata.get('_bad_msg'))
|
||||
and
|
||||
isinstance(_bad_msg, PayloadMsg)
|
||||
and (
|
||||
isinstance(_bad_msg, PayloadMsg)
|
||||
or
|
||||
isinstance(_bad_msg, msgtypes.Start)
|
||||
)
|
||||
):
|
||||
return _bad_msg
|
||||
|
||||
|
@ -1015,18 +1030,6 @@ 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,
|
||||
|
||||
|
@ -1206,7 +1209,7 @@ def is_multi_cancelled(
|
|||
trio.Cancelled in ignore_nested
|
||||
# XXX always count-in `trio`'s native signal
|
||||
):
|
||||
ignore_nested |= {trio.Cancelled}
|
||||
ignore_nested.update({trio.Cancelled})
|
||||
|
||||
if isinstance(exc, BaseExceptionGroup):
|
||||
matched_exc: BaseExceptionGroup|None = exc.subgroup(
|
||||
|
|
Loading…
Reference in New Issue