From 56c19093bbafdbfc283865244d72ee2211302a94 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 6 Jul 2022 10:49:39 -0400 Subject: [PATCH] Add basic module-not-found when opening a ctx eg. --- examples/debugging/open_ctx_modnofound.py | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/debugging/open_ctx_modnofound.py diff --git a/examples/debugging/open_ctx_modnofound.py b/examples/debugging/open_ctx_modnofound.py new file mode 100644 index 0000000..181295a --- /dev/null +++ b/examples/debugging/open_ctx_modnofound.py @@ -0,0 +1,40 @@ +import trio +import tractor + + +@tractor.context +async def just_sleep( + + ctx: tractor.Context, + **kwargs, + +) -> None: + ''' + Start and sleep. + + ''' + await ctx.started() + await trio.sleep_forever() + + +async def main() -> None: + + async with tractor.open_nursery( + debug_mode=True, + ) as n: + portal = await n.start_actor( + 'ctx_child', + + # XXX: we don't enable the current module in order + # to trigger `ModuleNotFound`. + enable_modules=[], + ) + + async with portal.open_context( + just_sleep, # taken from pytest parameterization + ) as (ctx, sent): + raise KeyboardInterrupt + + +if __name__ == '__main__': + trio.run(main)