-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test showing issue with child in tty lock when cancelled
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
examples/debugging/root_cancelled_but_child_is_in_tty_lock.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import tractor | ||
|
||
|
||
async def name_error(): | ||
"Raise a ``NameError``" | ||
getattr(doggypants) | ||
|
||
|
||
async def spawn_until(depth=0): | ||
""""A nested nursery that triggers another ``NameError``. | ||
""" | ||
async with tractor.open_nursery() as n: | ||
if depth < 1: | ||
# await n.run_in_actor('breakpoint_forever', breakpoint_forever) | ||
await n.run_in_actor('name_error', name_error) | ||
else: | ||
depth -= 1 | ||
await n.run_in_actor(f'spawn_until_{depth}', spawn_until, depth=depth) | ||
|
||
|
||
async def main(): | ||
"""The main ``tractor`` routine. | ||
The process tree should look as approximately as follows when the debugger | ||
first engages: | ||
python examples/debugging/multi_nested_subactors_bp_forever.py | ||
├─ python -m tractor._child --uid ('spawner1', '7eab8462 ...) | ||
│ └─ python -m tractor._child --uid ('spawn_until_0', '3720602b ...) | ||
│ └─ python -m tractor._child --uid ('name_error', '505bf71d ...) | ||
│ | ||
└─ python -m tractor._child --uid ('spawner0', '1d42012b ...) | ||
└─ python -m tractor._child --uid ('name_error', '6c2733b8 ...) | ||
""" | ||
async with tractor.open_nursery() as n: | ||
|
||
# spawn both actors | ||
portal = await n.run_in_actor('spawner0', spawn_until, depth=0) | ||
portal1 = await n.run_in_actor('spawner1', spawn_until, depth=1) | ||
|
||
# nursery cancellation should be triggered due to propagated error | ||
await portal.result() | ||
await portal1.result() | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True, loglevel='trace') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3917117
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaict this is something to do with a cancel message being sent to a subactor but that child is already in "synchronous land" blocking inside
pdb
.I'm not entirely sure I understand why the cancellation isn't triggering once the debugger is exited and the next checkpoint is hit..