-
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.
Merge pull request #129 from goodboy/multiproc_debug
Wen? Multiprocessing-native debugger now!
- Loading branch information
Showing
29 changed files
with
1,259 additions
and
151 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
examples/debugging/multi_nested_subactors_error_up_through_nurseries.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,58 @@ | ||
import tractor | ||
|
||
|
||
async def name_error(): | ||
"Raise a ``NameError``" | ||
getattr(doggypants) | ||
|
||
|
||
async def breakpoint_forever(): | ||
"Indefinitely re-enter debugger in child actor." | ||
while True: | ||
await tractor.breakpoint() | ||
|
||
|
||
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_3', 'afcba7a8 ...) | ||
│ └─ python -m tractor._child --uid ('spawn_until_2', 'd2433d13 ...) | ||
│ └─ python -m tractor._child --uid ('spawn_until_1', '1df589de ...) | ||
│ └─ python -m tractor._child --uid ('spawn_until_0', '3720602b ...) | ||
│ | ||
└─ python -m tractor._child --uid ('spawner0', '1d42012b ...) | ||
└─ python -m tractor._child --uid ('spawn_until_2', '2877e155 ...) | ||
└─ python -m tractor._child --uid ('spawn_until_1', '0502d786 ...) | ||
└─ python -m tractor._child --uid ('spawn_until_0', 'de918e6d ...) | ||
""" | ||
async with tractor.open_nursery() as n: | ||
|
||
# spawn both actors | ||
portal = await n.run_in_actor('spawner0', spawn_until, depth=3) | ||
portal1 = await n.run_in_actor('spawner1', spawn_until, depth=4) | ||
|
||
# gah still an issue here. | ||
# await portal.result() | ||
# await portal1.result() | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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,43 @@ | ||
import tractor | ||
|
||
|
||
async def name_error(): | ||
"Raise a ``NameError``" | ||
getattr(doggypants) | ||
|
||
|
||
async def spawn_error(): | ||
""""A nested nursery that triggers another ``NameError``. | ||
""" | ||
async with tractor.open_nursery() as n: | ||
portal = await n.run_in_actor('name_error_1', name_error) | ||
return await portal.result() | ||
|
||
|
||
async def main(): | ||
"""The main ``tractor`` routine. | ||
The process tree should look as approximately as follows: | ||
python examples/debugging/multi_subactors.py | ||
├─ python -m tractor._child --uid ('name_error', 'a7caf490 ...) | ||
`-python -m tractor._child --uid ('spawn_error', '52ee14a5 ...) | ||
`-python -m tractor._child --uid ('name_error', '3391222c ...) | ||
""" | ||
async with tractor.open_nursery() as n: | ||
|
||
# spawn both actors | ||
portal = await n.run_in_actor('name_error', name_error) | ||
portal1 = await n.run_in_actor('spawn_error', spawn_error) | ||
|
||
# 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__': | ||
tractor.run(main, debug_mode=True) |
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,47 @@ | ||
import tractor | ||
import trio | ||
|
||
|
||
async def breakpoint_forever(): | ||
"Indefinitely re-enter debugger in child actor." | ||
while True: | ||
await trio.sleep(0.1) | ||
await tractor.breakpoint() | ||
|
||
|
||
async def name_error(): | ||
"Raise a ``NameError``" | ||
getattr(doggypants) | ||
|
||
|
||
async def spawn_error(): | ||
""""A nested nursery that triggers another ``NameError``. | ||
""" | ||
async with tractor.open_nursery() as n: | ||
portal = await n.run_in_actor('name_error_1', name_error) | ||
return await portal.result() | ||
|
||
|
||
async def main(): | ||
"""The main ``tractor`` routine. | ||
The process tree should look as approximately as follows: | ||
-python examples/debugging/multi_subactors.py | ||
|-python -m tractor._child --uid ('name_error', 'a7caf490 ...) | ||
|-python -m tractor._child --uid ('bp_forever', '1f787a7e ...) | ||
`-python -m tractor._child --uid ('spawn_error', '52ee14a5 ...) | ||
`-python -m tractor._child --uid ('name_error', '3391222c ...) | ||
""" | ||
async with tractor.open_nursery() as n: | ||
|
||
# Spawn both actors, don't bother with collecting results | ||
# (would result in a different debugger outcome due to parent's | ||
# cancellation). | ||
await n.run_in_actor('bp_forever', breakpoint_forever) | ||
await n.run_in_actor('name_error', name_error) | ||
await n.run_in_actor('spawn_error', spawn_error) | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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,15 @@ | ||
import trio | ||
import tractor | ||
|
||
|
||
async def main(): | ||
|
||
await trio.sleep(0.1) | ||
|
||
await tractor.breakpoint() | ||
|
||
await trio.sleep(0.1) | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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,11 @@ | ||
import tractor | ||
|
||
|
||
async def main(): | ||
|
||
while True: | ||
await tractor.breakpoint() | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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,9 @@ | ||
import tractor | ||
|
||
|
||
async def main(): | ||
assert 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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='warning') |
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,25 @@ | ||
import trio | ||
import tractor | ||
|
||
|
||
async def breakpoint_forever(): | ||
"""Indefinitely re-enter debugger in child actor. | ||
""" | ||
while True: | ||
await trio.sleep(0.1) | ||
await tractor.breakpoint() | ||
|
||
|
||
async def main(): | ||
|
||
async with tractor.open_nursery() as n: | ||
|
||
portal = await n.run_in_actor( | ||
'breakpoint_forever', | ||
breakpoint_forever, | ||
) | ||
await portal.result() | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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,16 @@ | ||
import tractor | ||
|
||
|
||
async def name_error(): | ||
getattr(doggypants) | ||
|
||
|
||
async def main(): | ||
async with tractor.open_nursery() as n: | ||
|
||
portal = await n.run_in_actor('name_error', name_error) | ||
await portal.result() | ||
|
||
|
||
if __name__ == '__main__': | ||
tractor.run(main, debug_mode=True) |
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ pytest-trio | |
pdbpp | ||
mypy | ||
trio_typing | ||
pexpect |
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
Oops, something went wrong.