[concurrent.futures.interpreter] Update to 3.14.0b4 (#14522)

This commit is contained in:
Semyon Moroz
2025-08-04 18:59:26 -07:00
committed by GitHub
parent f57e8b1f26
commit 084742b431
4 changed files with 22 additions and 51 deletions
@@ -2,14 +2,6 @@
# TODO: New errors in Python 3.14 that need to be fixed or moved below
# ====================================================================
concurrent.futures.InterpreterPoolExecutor.__init__
concurrent.futures.InterpreterPoolExecutor.prepare_context
concurrent.futures.interpreter.ExecutionFailed
concurrent.futures.interpreter.InterpreterPoolExecutor.__init__
concurrent.futures.interpreter.InterpreterPoolExecutor.prepare_context
concurrent.futures.interpreter.WorkerContext.__init__
concurrent.futures.interpreter.WorkerContext.prepare
concurrent.futures.interpreter.do_call
multiprocessing.managers.BaseListProxy.clear
multiprocessing.managers.BaseListProxy.copy
multiprocessing.managers.DictProxy.__ior__
@@ -47,7 +47,7 @@ if sys.version_info >= (3, 14):
with InterpreterPoolExecutor(initializer=_initializer, initargs=("x",)): # type: ignore
...
context = InterpreterPoolExecutor.prepare_context(initializer=_initializer, initargs=(1,), shared={})
context = InterpreterPoolExecutor.prepare_context(initializer=_initializer, initargs=(1,))
worker_context = context[0]()
assert_type(worker_context, concurrent.futures.interpreter.WorkerContext)
resolve_task = context[1]
+2 -2
View File
@@ -34,8 +34,8 @@ def exec(
def call(
id: SupportsIndex,
callable: Callable[..., _R],
args: tuple[object, ...] | None = None,
kwargs: dict[str, object] | None = None,
args: tuple[Any, ...] | None = None,
kwargs: dict[str, Any] | None = None,
*,
restrict: bool = False,
) -> tuple[_R, types.SimpleNamespace]: ...
+19 -40
View File
@@ -1,10 +1,13 @@
import sys
from collections.abc import Callable, Mapping
from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
from typing import Literal, Protocol, overload, type_check_only
from typing import Any, Literal, Protocol, overload, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple, Unpack
_Task: TypeAlias = tuple[bytes, Literal["function", "script"]]
_Ts = TypeVarTuple("_Ts")
_P = ParamSpec("_P")
_R = TypeVar("_R")
@type_check_only
class _TaskFunc(Protocol):
@@ -13,62 +16,41 @@ class _TaskFunc(Protocol):
@overload
def __call__(self, fn: str) -> tuple[bytes, Literal["script"]]: ...
_Ts = TypeVarTuple("_Ts")
_P = ParamSpec("_P")
_R = TypeVar("_R")
# A `type.simplenamespace` with `__name__` attribute.
@type_check_only
class _HasName(Protocol):
__name__: str
# `_interpreters.exec` technically gives us a simple namespace.
@type_check_only
class _ExcInfo(Protocol):
formatted: str
msg: str
type: _HasName
if sys.version_info >= (3, 14):
from concurrent.futures.thread import BrokenThreadPool, WorkerContext as ThreadWorkerContext
from concurrent.interpreters import Interpreter, Queue
from _interpreters import InterpreterError
class ExecutionFailed(InterpreterError):
def __init__(self, excinfo: _ExcInfo) -> None: ... # type: ignore[override]
def do_call(results: Queue, func: Callable[..., _R], args: tuple[Any, ...], kwargs: dict[str, Any]) -> _R: ...
class WorkerContext(ThreadWorkerContext):
# Parent class doesn't have `shared` argument,
@overload # type: ignore[override]
interp: Interpreter | None
results: Queue | None
@overload # type: ignore[override]
@classmethod
def prepare(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], Self], _TaskFunc]: ...
@overload # type: ignore[override]
@overload
@classmethod
def prepare(
cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
) -> tuple[Callable[[], Self], _TaskFunc]: ...
def __init__(
self, initdata: tuple[bytes, Literal["function", "script"]], shared: Mapping[str, object] | None = None
) -> None: ... # type: ignore[override]
def prepare(cls, initializer: Callable[[], object], initargs: tuple[()]) -> tuple[Callable[[], Self], _TaskFunc]: ...
def __init__(self, initdata: _Task) -> None: ...
def __del__(self) -> None: ...
def run(self, task: _Task) -> None: ... # type: ignore[override]
def run(self, task: _Task) -> None: ... # type: ignore[override]
class BrokenInterpreterPool(BrokenThreadPool): ...
class InterpreterPoolExecutor(ThreadPoolExecutor):
BROKEN: type[BrokenInterpreterPool]
@overload # type: ignore[override]
@overload # type: ignore[override]
@classmethod
def prepare_context(
cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
cls, initializer: Callable[[], object], initargs: tuple[()]
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
@overload # type: ignore[override]
@overload
@classmethod
def prepare_context(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
@overload
def __init__(
@@ -77,7 +59,6 @@ if sys.version_info >= (3, 14):
thread_name_prefix: str = "",
initializer: Callable[[], object] | None = None,
initargs: tuple[()] = (),
shared: Mapping[str, object] | None = None,
) -> None: ...
@overload
def __init__(
@@ -87,7 +68,6 @@ if sys.version_info >= (3, 14):
*,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
shared: Mapping[str, object] | None = None,
) -> None: ...
@overload
def __init__(
@@ -96,5 +76,4 @@ if sys.version_info >= (3, 14):
thread_name_prefix: str,
initializer: Callable[[Unpack[_Ts]], object],
initargs: tuple[Unpack[_Ts]],
shared: Mapping[str, object] | None = None,
) -> None: ...