From 8c7256c8fdcac67f08db1c22db0776fde6a25349 Mon Sep 17 00:00:00 2001 From: Guo Ci Date: Sun, 23 Nov 2025 13:28:59 -0500 Subject: [PATCH] [stdlib] Add `locked` method to `threading.Condition` (#15075) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alex Waygood --- stdlib/@tests/stubtest_allowlists/py314.txt | 3 +++ stdlib/threading.pyi | 3 +++ 2 files changed, 6 insertions(+) diff --git a/stdlib/@tests/stubtest_allowlists/py314.txt b/stdlib/@tests/stubtest_allowlists/py314.txt index 0fcdcbb84..76d040873 100644 --- a/stdlib/@tests/stubtest_allowlists/py314.txt +++ b/stdlib/@tests/stubtest_allowlists/py314.txt @@ -40,6 +40,9 @@ concurrent.interpreters._queues.UNBOUND_REMOVE importlib.util.Loader.exec_module # See Lib/importlib/_abc.py. Might be defined for backwards compatibility +# Condition functions are exported in __init__ +threading.Condition.locked +multiprocessing.dummy.Condition.locked # ==================================== # Pre-existing errors from Python 3.13 diff --git a/stdlib/threading.pyi b/stdlib/threading.pyi index 7b0f15bdf..8a2b68dcd 100644 --- a/stdlib/threading.pyi +++ b/stdlib/threading.pyi @@ -144,6 +144,9 @@ class Condition: ) -> None: ... def acquire(self, blocking: bool = True, timeout: float = -1) -> bool: ... def release(self) -> None: ... + if sys.version_info >= (3, 14): + def locked(self) -> bool: ... + def wait(self, timeout: float | None = None) -> bool: ... def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ... def notify(self, n: int = 1) -> None: ...