trio
trio copied to clipboard
Add a method to get the traceback of a task
This PR adds a method to trio.Task to get a stack trace of a task. It is based on the example that was in the docs, but I added support for async generators. This was non-trivial as cpython doesn't expose the underlying generator object. I originally used a standalone function like this in a modified version of pytest-trio to support timeouts (I might upstream that later once I clean it up a bit). However, I felt that such a function would belong better in the main trio repo, where it can easily be used by others.
Codecov Report
Merging #2410 (3f3e55d) into master (25fe5c5) will increase coverage by
0.87%. The diff coverage is87.75%.
Additional details and impacted files
@@ Coverage Diff @@
## master #2410 +/- ##
==========================================
+ Coverage 98.01% 98.89% +0.87%
==========================================
Files 117 118 +1
Lines 16153 16202 +49
Branches 3126 3137 +11
==========================================
+ Hits 15833 16023 +190
+ Misses 259 126 -133
+ Partials 61 53 -8
| Impacted Files | Coverage Δ | |
|---|---|---|
| trio/_core/_run.py | 99.45% <72.22%> (-0.10%) |
:arrow_down: |
| trio/tests/test_tracing.py | 96.77% <96.77%> (ø) |
|
| trio/tests/test_ssl.py | 99.86% <0.00%> (+0.55%) |
:arrow_up: |
| trio/tests/test_socket.py | 99.83% <0.00%> (+0.64%) |
:arrow_up: |
| trio/_core/tests/test_io.py | 100.00% <0.00%> (+1.05%) |
:arrow_up: |
| trio/tests/test_highlevel_open_tcp_stream.py | 100.00% <0.00%> (+1.47%) |
:arrow_up: |
| trio/_subprocess_platform/__init__.py | 100.00% <0.00%> (+5.71%) |
:arrow_up: |
| trio/_highlevel_ssl_helpers.py | 100.00% <0.00%> (+11.76%) |
:arrow_up: |
| trio/_core/__init__.py | 100.00% <0.00%> (+12.50%) |
:arrow_up: |
| ... and 3 more |
ping
I'm in favour of this, not having to deal with the async generator introspection black hole is essentially useful enough to put it in trio itself, and it was clearly useful to put in the docs.
Hey @VincentVanlaer, it looks like that was the first time we merged one of your PRs! Thanks so much! :tada: :birthday:
If you want to keep contributing, we'd love to have you. So, I just sent you an invitation to join the python-trio organization on Github! If you accept, then here's what will happen:
-
Github will automatically subscribe you to notifications on all our repositories. (But you can unsubscribe again if you don't want the spam.)
-
You'll be able to help us manage issues (add labels, close them, etc.)
-
You'll be able to review and merge other people's pull requests
-
You'll get a [member] badge next to your name when participating in the Trio repos, and you'll have the option of adding your name to our member's page and putting our icon on your Github profile (details)
If you want to read more, here's the relevant section in our contributing guide.
Alternatively, you're free to decline or ignore the invitation. You'll still be able to contribute as much or as little as you like, and I won't hassle you about joining again. But if you ever change your mind, just let us know and we'll send another invitation. We'd love to have you, but more importantly we want you to do whatever's best for you.
If you have any questions, well... I am just a humble Python script, so I probably can't help. But please do post a comment here, or in our chat, or on our forum, whatever's easiest, and someone will help you out!