Giter Site home page Giter Site logo

Comments (3)

sentrivana avatar sentrivana commented on August 30, 2024 1

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.

sentrivana avatar sentrivana commented on August 30, 2024

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.

zaheerabbas-prodigal avatar zaheerabbas-prodigal commented on August 30, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.