Comments (3)
The reason for this is to prevent a circular reference which the GC cannot handle efficiently. Please see this issue for more details: #26 (and the official documentation of this behavior in the warning at https://docs.python.org/2/library/sys.html#sys.exc_info).
I'll add a code comment for those lines in the next release as it does look odd if the reader is unfamiliar with that behavior (it is rather counter-intuitive).
from raygun4py.
I think I understand what the code is trying to accomplish, but I still think it's broken. As I understand the docs you linked to, the recommended pattern for avoiding the circular reference is more something like this:
def some_exception_handler():
exc_type, exc_val, exc_tb = sys.exc_info()
try:
do_stuff_with_exc_info(exc_type, exc_val, exc_tb)
finally:
del exc_type, exc_val, exc_tb
The biggest distinction of note is that del
ing the references to the exc_info() values is not what needs to be guarded by the try clause, it's the cleanup action that needs to take place should anything you are doing with the exc_info values in the try clause throw any kind of exception.
del some_var
doesn't throw exceptions when the name some_var
is in scope, which it plainly is with just a quick glance at the code, so you don't need to wrap that in a try clause. As it sits now, the only way your except clause will be triggered is via some bug in the python interpreter. Not a very likely scenario.
Also, even if you were concerned about del exc_type, exc_value, exc_traceback
somehow failing in the try clause, the following two pieces of code are equivalent in python:
try:
do_something()
except Exception:
raise
and
do_something()
In other words, if you have nothing but raise
in your except clause, you might as well not wrap the try clause at all, because you're throwing the error up to your caller regardless.
from raygun4py.
Hi Don,
I'm inclined to agree with the analysis above, had a quick attempt during the last release at reproducing the actual behavior which didn't work. In order to confirm the impact of this change it looks like I'll need to create a proper repro and profile the GC to see the circular reference. This will allow us to verify removing the raise/altering the logic. As the code is running in production with no (reported) issues as this time we have a policy on not making breaking changes without evidence, so I'll be revisiting this issue and hopefully fixing the logic once I have time to create the repro.
from raygun4py.
Related Issues (20)
- How to stop sending environment variables with errors with flask HOT 2
- AttributeError: 'Provider' object has no attribute '_is_coroutine' HOT 1
- AttributeError: 'dict' object has no attribute 'localVariables' HOT 1
- SyntaxError: invalid syntax - middleware/wsgi.py", line 43 HOT 2
- Any good reason to pin down the dependencies? HOT 4
- wsgi middleware syntax error python3 HOT 2
- Support new middleware style for Django 1.10 HOT 1
- Pypi build version outdated HOT 1
- Push latest version to PyPi?
- when i pip install, it always installs python2 version, how can i install python3 version HOT 1
- AttributeError: 'NoneType' object has no attribute 'set_user'
- Add git tags when publishing HOT 1
- Environment Variables are always sent to Raygun HOT 6
- Add support for wildcard matching of environment variable blacklist HOT 2
- Update Documentation related to callback functions
- Update Documentation with Best Practices for subclassing an exception
- Crashed on logging error from a POST in Django HOT 1
- RaygunErrorMessage serializer code falls into infinite loop and crashes python
- Documentation for Custom grouping logic has incorrect definition of the callback parameter HOT 3
- RaygunHandler fails when logging outside of an exception context.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raygun4py.