tractor/examples/debugging/subactor_error.py

30 lines
743 B
Python
Raw Permalink Normal View History

2021-02-24 18:39:14 +00:00
import trio
2020-10-04 13:54:36 +00:00
import tractor
async def name_error():
getattr(doggypants) # noqa (on purpose)
2020-10-04 13:54:36 +00:00
async def main():
2021-02-24 18:39:14 +00:00
async with tractor.open_nursery(
debug_mode=True,
# loglevel='transport',
) as an:
2020-10-04 13:54:36 +00:00
# TODO: ideally the REPL arrives at this frame in the parent,
# ABOVE the @api_frame of `Portal.run_in_actor()` (which
# should eventually not even be a portal method ... XD)
# await tractor.pause()
p: tractor.Portal = await an.run_in_actor(name_error)
# with this style, should raise on this line
await p.result()
# with this alt style should raise at `open_nusery()`
# return await p.result()
2020-10-04 13:54:36 +00:00
if __name__ == '__main__':
2021-02-24 18:39:14 +00:00
trio.run(main)