-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
gh-100228: Warn from os.fork() if other threads exist. #100229
Conversation
Not comprehensive, best effort.
✅ Deploy Preview for python-cpython-preview canceled.
|
* Only warn in the parent process. * Add a test to test_os that a non-Python thread triggers the warning. * Avoid the system calls to count threads if we've already warned once. * The macOS API calls were written blind based on docs, will fix later if CI fails.
…o warn/os.fork/threads
I don't want the array of thread info but it may insist?
Misc/NEWS.d/next/Library/2022-12-13-17-29-09.gh-issue-100228.bgtzMV.rst
Outdated
Show resolved
Hide resolved
Let the thread free and clear things as it ends after we unblock it.
It could hide more than we intend and wouldn't do what I wanted in child processes that inherit the parents warnings state anyways.
…gtzMV.rst Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: T. Wouters <thomas@python.org>
Since python 3.12 python/cpython#100229, fork inside a multithreaded process will raise a warning. We actually have another solution to get rid of the fork that was implemented in more recent versions.
Since python 3.12 python/cpython#100229, fork inside a multithreaded process will raise a warning. We actually have another solution to get rid of the fork that was implemented in more recent versions. closes #163562 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
is the use of |
we can't disable it because people depend on it whether that's wise or not, but it is always the wrong thing to do. we're not going to create a "YouWillSufferMysteriousProblemsWarning" for such purposes. DeprecationWarning is accurate because it is something people used to do a lot but underlying platforms have significantly moved on such that things that relied on what they could get away with 15-20 years ago are no longer feasible in many normal environments today. the deadlocks can come from the platform level and other low level libraries including the C stdlib and malloc and whatnot. it does not matter if you think you interact with the threads at all, just that they exist and are running is enough to lead to scenarios outside your control where problems happen randomly when forking. for functions defined in the test themselves, the normal advise is to refactor the code so it is something pickle can handle (generally: not being defined on the fly) |
Where can I get your input on an issue I'm seeing where I dont actually see why this warning is being emitted? This has to do with the use of the pytest-xdist plugin which uses a tool called execnet. When using this plugin, if our own test uses fork, we get the warning. however, I've created a suite that runs through output can be seen as follows - as you can see I'm not able to find any additional threads that are known to the Python interpreter. So....execnet is spawning threads outside of the interpreter? is that what has to be happening? is that a bug for them?
I've looked at execnet a few times and so far it's opaque to me what it's doing or how pytest-xdist uses it. |
i've opened an issue at pytest-dev/pytest-xdist#1186 |
Not comprehensive, best effort warning. There are cases when threads exist that this code currently does not detect.
Starting with a
DeprecationWarning
for now, it is less disruptive than something likeRuntimeWarning
and most likely to only be seen in people's CI tests - a good place to start with this messaging.TODO: