Last active
February 17, 2017 10:22
-
-
Save njsmith/1c3742362bb6f5cc505f69cb66db2e71 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import sys | |
| import trio | |
| def dump_stack(where): | |
| print("-- {} --".format(where)) | |
| frame = sys._getframe(1) | |
| while frame: | |
| print(frame.f_code.co_name) | |
| frame = frame.f_back | |
| async def f(): | |
| dump_stack("f before yielding") | |
| await g() | |
| dump_stack("f after yielding") | |
| async def g(): | |
| dump_stack("g before yielding") | |
| await h() | |
| dump_stack("g after yielding") | |
| async def h(): | |
| dump_stack("h before yielding") | |
| await trio.sleep(0) | |
| dump_stack("h after yielding") | |
| trio.run(f) |
This file contains hidden or 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
| ~/trio$ python check-stack.py | |
| -- f before yielding -- | |
| f | |
| send | |
| run_impl | |
| run | |
| <module> | |
| -- g before yielding -- | |
| g | |
| f | |
| send | |
| run_impl | |
| run | |
| <module> | |
| -- h before yielding -- | |
| h | |
| g | |
| f | |
| send | |
| run_impl | |
| run | |
| <module> | |
| -- h after yielding -- | |
| h | |
| send | |
| run_impl | |
| run | |
| <module> | |
| -- g after yielding -- | |
| g | |
| send | |
| run_impl | |
| run | |
| <module> | |
| -- f after yielding -- | |
| f | |
| send | |
| run_impl | |
| run | |
| <module> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment