benoitc / gunicorn

gunicorn 'Green Unicorn' is a WSGI HTTP Server for UNIX, fast clients and sleepy applications.
http://www.gunicorn.org
Other
9.75k stars 1.74k forks source link

Deprecation warning for os.fork on Python 3.12 #3289

Open elishagreenwald opened 2 weeks ago

elishagreenwald commented 2 weeks ago

gunicorn version: ==23.0.0 gevent version: pypi ==24.2.1 Python version: 3.12.5 Operating System: Docker image python:3.12.5-bookworm (debian) Description: I'm seeing a deprecation warning when running gevent (via gunicorn) on python 3.12.5. It seems this warning was added in python 3.12 (see https://github.com/python/cpython/pull/109767 for more details)

The warning says:

/usr/local/lib/python3.12/site-packages/gevent/os.py:426: DeprecationWarning: This process (pid=17) is multi-threaded, use of fork() may lead to deadlocks in the child.

I found gunicorn makes calls to os.fork here.

I'm happy to provide more details but my question is, is this a known issue and is there anything to worry about?

Thanks!

pajod commented 2 weeks ago

Until someone comes up with a detectable scenario where the warning is wrong (at which point cPython could just implement that detection..) I am happy to consider each and every pathway to trigger it a bug worthy of, at the very least, improving documentation.

Its not a single case though, some (live python thread in master) imho should be stopped outright by Gunicorn because a clear recommendation of what to do instead can be provided. Other scenarios (fork+exec from arbiter) should at least produce sensible logging, eventually. And then clearly some scenarios were simply no big deal.. at least until free-threaded 3.13.

Please be specific which case you ask about. Ideally: quote a reproducer. At the very least what processes are running and what the sequence is from adding a native thread to triggering the warning from the (gevent-patched) fork() call. I am guessing you preloaded your application for the gevent worker, and your app is pulling in some "let's do funky stuff at import time" extension module?

elishagreenwald commented 1 week ago

Sorry for the delayed response. It turns out it's coming from ddtrace (datadog tracing) so I reached out to their support. Thanks!