tractor/examples/debugging/subactor_breakpoint.py

32 lines
593 B
Python
Raw Normal View History

2020-10-04 13:54:36 +00:00
import trio
import tractor
async def breakpoint_forever():
'''
Indefinitely re-enter debugger in child actor.
'''
2020-10-04 13:54:36 +00:00
while True:
await trio.sleep(0.1)
await tractor.pause()
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='cancel',
) as an:
2020-10-04 13:54:36 +00:00
# parks awaiting a result which only arrives once the
# user quits (`BdbQuit`s) the child's REPL loop.
await tractor.to_actor.run(
2020-10-04 13:54:36 +00:00
breakpoint_forever,
an=an,
2020-10-04 13:54:36 +00:00
)
if __name__ == '__main__':
2021-02-24 18:39:14 +00:00
trio.run(main)