diff options
author | Gregory P. Smith <greg@krypto.org> | 2022-12-29 22:41:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-29 22:41:39 (GMT) |
commit | 894f2c3c161933bd820ad322b3b678d89bc2377c (patch) | |
tree | 9c41c6fe2ce16ab42d7fc35223eeca1c061ea269 /Lib/threading.py | |
parent | 2df82db48506e5a2044a28f147fdb42f662d37b9 (diff) | |
download | cpython-894f2c3c161933bd820ad322b3b678d89bc2377c.zip cpython-894f2c3c161933bd820ad322b3b678d89bc2377c.tar.gz cpython-894f2c3c161933bd820ad322b3b678d89bc2377c.tar.bz2 |
gh-100228: Warn from os.fork() if other threads exist. (#100229)
Not comprehensive, best effort warning. There are cases when threads exist on some platforms that this code cannot detect. macOS when API permissions allow and Linux with a readable /proc procfs present are the currently supported cases where a warning should show up reliably.
Starting with a DeprecationWarning for now, it is less disruptive than something like RuntimeWarning and most likely to only be seen in people's CI tests - a good place to start with this messaging.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r-- | Lib/threading.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/threading.py b/Lib/threading.py index 723bd58..df27387 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -1490,6 +1490,8 @@ def active_count(): enumerate(). """ + # NOTE: if the logic in here ever changes, update Modules/posixmodule.c + # warn_about_fork_with_threads() to match. with _active_limbo_lock: return len(_active) + len(_limbo) |