-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Sentry SDK in worker leads to crash #261
Comments
Hi and thanks for creating this report. But I'm not sure how we can solve it, because it's a MacOS related issue only. Here's the origin on this issue: ansible/ansible#32499 (comment). Maybe you'll be able to resolve the issue by running this command before starting the worker: export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES |
Setting that environment variable doesn't work unfortunately, but the log output changes to:
Even though this error is clearly rooted somewhere in macOS there must be a workaround. Taskiq is the only framework I've encountered this with, and I've been using hot reloading and Sentry with FastAPI, Dramatiq, Celery, etc. |
I guess I have a possible solution. I will publish it soon. Will you be able to install taskiq from the branch to verify that the problem is gone? |
Ah, nice one! Yes, no problem. |
The branch is called |
It's still not working, but the error is different:
|
Okay. That was initial error that we were avoiding when choosing fork instead of spawn for macos. Let me give you a small overview of what is happening: Because we used to use fork method, the macos security considerations disallow spawning another fork from forked process (as I understood). Maybe because infinite forking might lead to the fork-bomb exploit or something. The initial problem we observed happened because sentry tries to spawns another process that sends all the data to the sentry using fork method and fails to spawn it because of macOS' securities. If we change the multiprocessing method to spawn, which is "safer" from macos perspective, then we observe another problem. Now processes cannot be started because of This is how I see the problem. I see one possible solution. It's to start using Have a nice day. |
Thanks for the detailed explanation. That all makes sense. I'm very happy to help solve this issue! By the way, it may be good to set up automated tests to also run on GitHub Actions macOS runners. That way you can make sure Taskiq continues to work on macOS without you having a Mac yourself. |
We already use it for most places. But CLI and process manager is one of parts that is missing coverage. I will try to add integration testing later. But it's really hard to verify and test. |
@itssimon, hi! At first I came up with quite crazy idea of having info-server, but I disliked the way it goes, so I just removed the event. Can you try running taskiq from the branch feature/new-process-mgr? If it solves the issue, we might merge it, but with some additional changes. |
(Disregard my previous deleted comment.) Running taskiq from that feature branch does indeed resolve the issue. |
Great. I will publish it after some small updates . |
Yes, true. Thanks for noticing. |
The Taskiq workers crash immediately if I initialise the Sentry SDK in the worker startup handler.
The worker startup handler looks like this:
This doesn't happen if I don't use Sentry, or if I start the worker without the
--reload
flag.Environment:
The text was updated successfully, but these errors were encountered: