This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Catch uncaught exception from thread#723
Open
PierreF wants to merge 1 commit intogetsentry:masterfrom
Open
Conversation
Contributor
|
I think this would need some fine tuning. In the current form that seems dangerous. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Raven use excepthook to catch uncaught exception, but this only work for main thread. If you spawn any other thread (using threading.Thread), any uncaught exception will be catched but threading.Thread and just print on stderr.
There is a known bug on Python that didn't evolved for years : http://bugs.python.org/issue1230540
On this bug, some workaround exists. This PR propose to integrate a workaround in raven client. Like the excepthook, it install an hook for thread when raven client is initialized.
It has the limitation that raven client must be initialized before creating other thread, or the hook won't be activated for that thread.
The following script show the issue: without the PR, the exception is only printed on stderr. With the PR, the exception is sent to Sentry and printed to stderr.