Comments (3)
Is there any other way we could make the sentry integration work?
Not that I know of. We're usually happy to either patch or work around things in libraries and frameworks that don't work with the SDK but the missing fork hooks is something so fundamental that there's not much we can do about it. The only solution as long as the upstream PR is not merged is to skip the broken forking altogether with --lazy-apps
or, unfortunately, to switch away from uWSGI.
Has no one else in the community faced this problem with uWSGI <> Sentry post Python 3.7+ changes where this was introduced?
We've only started recommending using --py-call-uwsgi-fork-hooks
fairly recently which might explain why there haven't been other reports about this so far. That being said, I didn't encounter this myself while working on the original issue. Granted, I was using a very bare-bones Flask app to repro and wasn't doing any logging
stuff in the app itself, but things were still being logged indirectly via e.g. the SDK's debug mode. So the RuntimeError
might be triggered by something specific in your logging setup -- it's a long shot but playing around with where and when you log things that might also be a workaround.
from sentry-python.
Hey @zaheerabbas-prodigal, thank you for reporting and for providing all the details!
As far as I can tell this is caused by uWSGI not calling all the necessary fork hooks. Basically, in pre-fork mode, everything is initialized in one process that is then forked into additional workers. When forking a process, C extensions are expected to call PyOS_BeforeFork()
, PyOS_AfterFork_Parent()
in the parent and PyOS_AfterFork_Child()
in the child to do stuff like clean up threads in the child processes.
The problem is that by default, uWSGI calls none of them. If you supply --py-call-uwsgi-fork-hooks
as we recommend, PyOS_AfterFork_Child()
will be called (and take care of some of the necessary thread cleanup), but the other two hooks still won't, and I assume PyOS_BeforeFork()
acquires the logging lock in question that PyOS_AfterFork_Child()
is then trying to release.
There is a long standing uWSGI pull request to utilize all three hooks.
As for what to do in your case, you can disable pre-forking mode completely with --lazy-apps
, in which case every worker sets up the app itself and there is no broken forking involved.
from sentry-python.
@sentrivana - thank you for explaining the issue. I appreciate the quick response.
I have asked an update on the PR you linked. The lazy-app
might cause some memory issues for us. Is there any other way we could make the sentry integration work? Has no one else in the community faced this problem with uWSGI <> Sentry post Python 3.7+ changes where this was introduced?
from sentry-python.
Related Issues (20)
- [Crons] Connection closing due to a timeout causing failed monitors HOT 2
- Internal error in sentry_sdk HOT 11
- Performance monitoring for streaming responses
- Fastapi: Url with path param without replacement in profiles_sampler and/or before_send_transaction HOT 4
- AWS Lambda failing w/ RuntimeError: can't start new thread on 1.40.3 HOT 1
- Make EventScrubber recursive HOT 3
- Auto instrumented Celery tasks have mismatching environment values between the first and second check-ins HOT 7
- Python metrics cause transaction duration changes
- Hubs & Scopes missing tasks HOT 3
- Cron monitor check-in fails due to backend errors in event flushing HOT 9
- Sentry doesn't support loguru level=trace HOT 1
- Instructions in `CONTRIBUTING.md` lead to an incomplete environment HOT 3
- SDK stuck in processing RecursionError:maximum recursion depth exceeded events HOT 1
- GrapheneIntegration: Enhance Transaction Naming for Errors in Graphene GraphQL Operations HOT 5
- Cronjob monitoring isn't very ergonomic if you're not using an automatic integration HOT 8
- ImportWarning caused by integrations on Python 3.10 HOT 3
- Add file name and line number to logentry
- Update all integrations to use the new Scope API and document it HOT 1
- Fix AWS Lambda tests
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 sentry-python.