2021-10-14 03:34:25 +00:00
|
|
|
'''
|
|
|
|
Test that a nested nursery will avoid clobbering
|
|
|
|
the debugger latched by a broken child.
|
|
|
|
|
|
|
|
'''
|
2021-02-24 18:39:14 +00:00
|
|
|
import trio
|
2020-10-05 15:38:39 +00:00
|
|
|
import tractor
|
|
|
|
|
|
|
|
|
|
|
|
async def name_error():
|
|
|
|
"Raise a ``NameError``"
|
2021-02-24 18:39:14 +00:00
|
|
|
getattr(doggypants) # noqa
|
2020-10-05 15:38:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def spawn_error():
|
|
|
|
""""A nested nursery that triggers another ``NameError``.
|
|
|
|
"""
|
|
|
|
async with tractor.open_nursery() as n:
|
2020-12-21 14:09:55 +00:00
|
|
|
portal = await n.run_in_actor(
|
|
|
|
name_error,
|
|
|
|
name='name_error_1',
|
|
|
|
)
|
2020-10-05 15:38:39 +00:00
|
|
|
return await portal.result()
|
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
"""The main ``tractor`` routine.
|
|
|
|
|
|
|
|
The process tree should look as approximately as follows:
|
|
|
|
|
2020-10-06 13:21:53 +00:00
|
|
|
python examples/debugging/multi_subactors.py
|
|
|
|
├─ python -m tractor._child --uid ('name_error', 'a7caf490 ...)
|
2020-10-05 15:38:39 +00:00
|
|
|
`-python -m tractor._child --uid ('spawn_error', '52ee14a5 ...)
|
|
|
|
`-python -m tractor._child --uid ('name_error', '3391222c ...)
|
2020-12-26 20:11:42 +00:00
|
|
|
|
|
|
|
Order of failure:
|
|
|
|
- nested name_error sub-sub-actor
|
|
|
|
- root actor should then fail on assert
|
|
|
|
- program termination
|
2020-10-05 15:38:39 +00:00
|
|
|
"""
|
2021-02-24 18:39:14 +00:00
|
|
|
async with tractor.open_nursery(
|
|
|
|
debug_mode=True,
|
2021-10-14 03:34:25 +00:00
|
|
|
# loglevel='cancel',
|
2021-02-24 18:39:14 +00:00
|
|
|
) as n:
|
2020-10-05 15:38:39 +00:00
|
|
|
|
|
|
|
# spawn both actors
|
2020-12-21 14:09:55 +00:00
|
|
|
portal = await n.run_in_actor(
|
|
|
|
name_error,
|
|
|
|
name='name_error',
|
|
|
|
)
|
|
|
|
portal1 = await n.run_in_actor(
|
|
|
|
spawn_error,
|
|
|
|
name='spawn_error',
|
|
|
|
)
|
2020-10-05 15:38:39 +00:00
|
|
|
|
|
|
|
# trigger a root actor error
|
|
|
|
assert 0
|
|
|
|
|
|
|
|
# attempt to collect results (which raises error in parent)
|
|
|
|
# still has some issues where the parent seems to get stuck
|
|
|
|
await portal.result()
|
|
|
|
await portal1.result()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2021-02-24 18:39:14 +00:00
|
|
|
trio.run(main)
|