forked from goodboy/tractor
1
0
Fork 0
tractor/examples/debugging/subactor_bp_in_ctx.py

50 lines
886 B
Python
Raw Normal View History

2022-01-27 04:38:33 +00:00
import tractor
import trio
async def gen():
yield 'yo'
await tractor.breakpoint()
yield 'yo'
2022-01-27 04:38:33 +00:00
@tractor.context
async def just_bp(
ctx: tractor.Context,
) -> None:
await ctx.started('yo bpin here')
await tractor.breakpoint()
# async for val in gen():
# print(val)
await trio.sleep(0.5)
# THIS CAUSES AN UNRECOVERABLE HANG!?
assert 0
2022-01-27 04:38:33 +00:00
async def main():
async with tractor.open_nursery(
loglevel='transport',
2022-01-27 04:38:33 +00:00
debug_mode=True,
) as n:
p = await n.start_actor(
'bp_boi',
enable_modules=[__name__],
# debug_mode=True,
2022-01-27 04:38:33 +00:00
)
async with p.open_context(
just_bp,
) as (ctx, first):
# await tractor.breakpoint()
# breakpoint()
2022-01-27 04:38:33 +00:00
await trio.sleep_forever()
if __name__ == '__main__':
trio.run(main)