-
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.
Restore
breakpoint()
hook after runtime exits
Previously we were leaking our (pdb++) override into the Python runtime which would always result in a runtime error whenever `breakpoint()` is called outside our runtime; after exit of the root actor . This explicitly restores any previous hook override (detected during startup) or deletes the hook and restores the environment if none existed prior. Also adds a new WIP debugging example script to ensure breakpointing works as normal after runtime close; this will be added to the test suite.
- Loading branch information
Showing
2 changed files
with
39 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import sys | ||
|
||
import trio | ||
import tractor | ||
|
||
|
||
async def main() -> None: | ||
async with tractor.open_nursery(debug_mode=True) as an: | ||
|
||
assert os.environ['PYTHONBREAKPOINT'] == 'tractor._debug._set_trace' | ||
|
||
# TODO: an assert that verifies the hook has indeed been, hooked | ||
# XD | ||
assert sys.breakpointhook is not tractor._debug._set_trace | ||
|
||
breakpoint() | ||
|
||
# TODO: an assert that verifies the hook is unhooked.. | ||
assert sys.breakpointhook | ||
breakpoint() | ||
|
||
if __name__ == '__main__': | ||
trio.run(main) |
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