Fix AttributeError on shutdown when threading.Thread is replaced mid-tracking#910
Merged
Merged
Conversation
godlygeek
requested changes
Apr 28, 2026
Contributor
godlygeek
left a comment
There was a problem hiding this comment.
Looks reasonable. Like the other PRs, should only have the last commit, and needs a Signed-off-by line with your real name in it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #910 +/- ##
==========================================
+ Coverage 92.46% 92.48% +0.02%
==========================================
Files 99 99
Lines 11748 11754 +6
Branches 427 427
==========================================
+ Hits 10863 10871 +8
+ Misses 885 883 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
610a976 to
b59a906
Compare
Contributor
Author
|
@godlygeek addressed: switched test to monkeypatch fixture, added |
Tracker now records the `threading.Thread` subclass it patched on entry and removes its instrumentation from that same class on exit, ignoring `AttributeError` defensively. Fixes a crash seen when scripts call `gevent.monkey.patch_all` while tracking is active, modifying what `threading.Thread` refers to underneath us. Signed-off-by: Suyog Bhise <bhise.suyog@gmail.com>
b59a906 to
924935d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #856
Summary
Tracker.__enter__instrumentsthreading.Threadby setting_nameand_identdescriptors on the class.threading.Threadduring tracking (notablygevent.monkey.patch_all()),Tracker.__exit__previously looked upthreading.Threadagain and tried todelattrfrom a different class,raising
AttributeError.AttributeErrorsuppression.Test plan
tests/unit/test_tracker.pyswapsthreading.Threadmid-context.