-
Notifications
You must be signed in to change notification settings - Fork 520
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
Make SDK safe for working with multiprocessing with the forkserver
start method
#3937
Comments
thanks for the detailed issue @n1ngu
I agree that Sentry cannot make assumptions about user applications and what they want to do. I will add this as documentation in our troubleshooting section so that users can get rid of the warning.
Regarding this, I need to figure out best practice for what to do, so I will leave this issue open (with a rename). |
forkserver
start method
@n1ngu I'm actually not seeing the deprecation warning on my system
are you using the exact same snippet you pasted above? |
Hi @sl0thentr0py thanks for taking a look into it. I believe the warning may be concealed by default, try with I tried to test it with that exact script but my dev environ is far from clean and may feature something else I am unaware of. |
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.19.2
Steps to Reproduce
On python 3.12 and a non-MacOS, non-Windows platform
See the warning show up.
Expected Result
os.fork()
is introduced by Sentry SDK without the users knowing.Actual Result
Capturing warnings in sentry has recently surfaced this issue to me. I don't quite understand the subtleties of the fork method problems so please bear with me and refer to other sources for technical details
'fork'
is broken: change to `'forkserver' || 'spawn'
python/cpython#84559A conservative (safe but slow) workaround is to issue
in the application before any multiprocessing pool is started or use
multiprocessing.get_context("spawn")
for libraries used alongside sentry, or let such contexts be injected in your libraries in general.AFAIU using the future "forkserver" default (on python 3.14) will not solve this problem because sentry is usually initialized very soon in the application configuration and I can't imagine a pool initialization procedure that will not initialize sentry in the fork server process in my applications. E.g. I am calling
sentry_sdk.init
on a sitecustomize.py module. I may understand this wrong, hopefully.It could be argued that Sentry can't do anything about it because it is up to the application to opt-out of the default fork method, but maybe this would be worth being documented? I mean it would be reckless to configure a global
multiprocessing.set_start_method
from a library like sentry, and sentry does not directly use a process pool so it can neither take care to use a safe context internally, but sentry starts threads in the main process making any default use of process pools unsafe to applications that would be single-threaded otherwise.Suffice to say, I have detected no actual deadlocks or other issues due to this (this has been a very concealed issue in posix platforms for years now)
related #291
The text was updated successfully, but these errors were encountered: