2021-05-10 11:46:16 +00:00
|
|
|
import trio
|
|
|
|
|
import tractor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def key_error():
|
|
|
|
|
"Raise a ``NameError``"
|
|
|
|
|
return {}['doggy']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
2026-05-01 04:13:22 +00:00
|
|
|
'''
|
|
|
|
|
Root is fail-after-cancelled while blocking and child RPC fails
|
|
|
|
|
simultaneously.
|
2021-05-10 11:46:16 +00:00
|
|
|
|
2026-05-01 04:13:22 +00:00
|
|
|
'''
|
2026-07-06 16:24:29 +00:00
|
|
|
async with (
|
|
|
|
|
tractor.open_nursery(
|
|
|
|
|
debug_mode=True,
|
|
|
|
|
# loglevel='debug' # ?XXX required?
|
2026-07-06 17:26:55 +00:00
|
|
|
) as an,
|
2026-07-06 16:24:29 +00:00
|
|
|
trio.open_nursery() as tn,
|
|
|
|
|
):
|
|
|
|
|
# spawn the actor..
|
2026-07-06 17:26:55 +00:00
|
|
|
portal = await an.start_actor(
|
2026-07-06 16:24:29 +00:00
|
|
|
'key_error',
|
|
|
|
|
enable_modules=[__name__],
|
|
|
|
|
)
|
2026-05-01 04:13:22 +00:00
|
|
|
print(
|
|
|
|
|
f'Child is up @ {portal.chan.aid.reprol()}'
|
|
|
|
|
)
|
2026-07-06 16:24:29 +00:00
|
|
|
# ..then schedule its erroring task in the bg while the
|
|
|
|
|
# root blocks below.
|
|
|
|
|
tn.start_soon(portal.run, key_error)
|
2021-05-10 11:46:16 +00:00
|
|
|
|
2021-08-01 14:43:21 +00:00
|
|
|
# XXX: originally a bug caused by this is where root would enter
|
|
|
|
|
# the debugger and clobber the tty used by the repl even though
|
|
|
|
|
# child should have it locked.
|
2021-05-10 11:46:16 +00:00
|
|
|
with trio.fail_after(1):
|
|
|
|
|
await trio.Event().wait()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
trio.run(main)
|