Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-100228: Warn from os.fork() if other threads exist.#100229
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Not comprehensive, best effort.
netlifybot commentedDec 14, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview forpython-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?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Misc/NEWS.d/next/Library/2022-12-13-17-29-09.gh-issue-100228.bgtzMV.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 childprocesses that inherit the parents warnings state anyways.
…gtzMV.rstCo-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: T. Wouters <thomas@python.org>
Since python 3.12python/cpython#100229, forkinside a multithreaded process will raise a warning.We actually have another solution to get rid of the fork that wasimplemented in more recent versions.
Since python 3.12python/cpython#100229, forkinside a multithreaded process will raise a warning.We actually have another solution to get rid of the fork that wasimplemented in more recent versions.closes#163562Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
zzzeek commentedMar 6, 2025
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 youthink 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) |
zzzeek commentedMar 6, 2025
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 thepytest-xdist plugin which uses a tool calledexecnet. 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. |
zzzeek commentedMar 6, 2025
i've opened an issue atpytest-dev/pytest-xdist#1186 |
Uh oh!
There was an error while loading.Please reload this page.
Not comprehensive, best effort warning. There are cases when threads exist that this code currently does not detect.
Starting with a
DeprecationWarningfor now, it is less disruptive than something likeRuntimeWarningand most likely to only be seen in people's CI tests - a good place to start with this messaging.TODO: