Skip to content

Commit 084742b

Browse files
authored
[concurrent.futures.interpreter] Update to 3.14.0b4 (#14522)
1 parent f57e8b1 commit 084742b

File tree

4 files changed

+22
-51
lines changed

4 files changed

+22
-51
lines changed

stdlib/@tests/stubtest_allowlists/py314.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22
# TODO: New errors in Python 3.14 that need to be fixed or moved below
33
# ====================================================================
44

5-
concurrent.futures.InterpreterPoolExecutor.__init__
6-
concurrent.futures.InterpreterPoolExecutor.prepare_context
7-
concurrent.futures.interpreter.ExecutionFailed
8-
concurrent.futures.interpreter.InterpreterPoolExecutor.__init__
9-
concurrent.futures.interpreter.InterpreterPoolExecutor.prepare_context
10-
concurrent.futures.interpreter.WorkerContext.__init__
11-
concurrent.futures.interpreter.WorkerContext.prepare
12-
concurrent.futures.interpreter.do_call
135
multiprocessing.managers.BaseListProxy.clear
146
multiprocessing.managers.BaseListProxy.copy
157
multiprocessing.managers.DictProxy.__ior__

stdlib/@tests/test_cases/check_concurrent_futures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def check_interpreter_pool_executor() -> None:
4747
with InterpreterPoolExecutor(initializer=_initializer, initargs=("x",)): # type: ignore
4848
...
4949

50-
context = InterpreterPoolExecutor.prepare_context(initializer=_initializer, initargs=(1,), shared={})
50+
context = InterpreterPoolExecutor.prepare_context(initializer=_initializer, initargs=(1,))
5151
worker_context = context[0]()
5252
assert_type(worker_context, concurrent.futures.interpreter.WorkerContext)
5353
resolve_task = context[1]

stdlib/_interpreters.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def exec(
3434
def call(
3535
id: SupportsIndex,
3636
callable: Callable[..., _R],
37-
args: tuple[object, ...] | None = None,
38-
kwargs: dict[str, object] | None = None,
37+
args: tuple[Any, ...] | None = None,
38+
kwargs: dict[str, Any] | None = None,
3939
*,
4040
restrict: bool = False,
4141
) -> tuple[_R, types.SimpleNamespace]: ...
Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import sys
2-
from collections.abc import Callable, Mapping
2+
from collections.abc import Callable
33
from concurrent.futures import ThreadPoolExecutor
4-
from typing import Literal, Protocol, overload, type_check_only
4+
from typing import Any, Literal, Protocol, overload, type_check_only
55
from typing_extensions import ParamSpec, Self, TypeAlias, TypeVar, TypeVarTuple, Unpack
66

77
_Task: TypeAlias = tuple[bytes, Literal["function", "script"]]
8+
_Ts = TypeVarTuple("_Ts")
9+
_P = ParamSpec("_P")
10+
_R = TypeVar("_R")
811

912
@type_check_only
1013
class _TaskFunc(Protocol):
@@ -13,62 +16,41 @@ class _TaskFunc(Protocol):
1316
@overload
1417
def __call__(self, fn: str) -> tuple[bytes, Literal["script"]]: ...
1518

16-
_Ts = TypeVarTuple("_Ts")
17-
_P = ParamSpec("_P")
18-
_R = TypeVar("_R")
19-
20-
# A `type.simplenamespace` with `__name__` attribute.
21-
@type_check_only
22-
class _HasName(Protocol):
23-
__name__: str
24-
25-
# `_interpreters.exec` technically gives us a simple namespace.
26-
@type_check_only
27-
class _ExcInfo(Protocol):
28-
formatted: str
29-
msg: str
30-
type: _HasName
31-
3219
if sys.version_info >= (3, 14):
3320
from concurrent.futures.thread import BrokenThreadPool, WorkerContext as ThreadWorkerContext
21+
from concurrent.interpreters import Interpreter, Queue
3422

35-
from _interpreters import InterpreterError
36-
37-
class ExecutionFailed(InterpreterError):
38-
def __init__(self, excinfo: _ExcInfo) -> None: ... # type: ignore[override]
23+
def do_call(results: Queue, func: Callable[..., _R], args: tuple[Any, ...], kwargs: dict[str, Any]) -> _R: ...
3924

4025
class WorkerContext(ThreadWorkerContext):
41-
# Parent class doesn't have `shared` argument,
42-
@overload # type: ignore[override]
26+
interp: Interpreter | None
27+
results: Queue | None
28+
@overload # type: ignore[override]
4329
@classmethod
4430
def prepare(
45-
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
31+
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
4632
) -> tuple[Callable[[], Self], _TaskFunc]: ...
47-
@overload # type: ignore[override]
33+
@overload
4834
@classmethod
49-
def prepare(
50-
cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
51-
) -> tuple[Callable[[], Self], _TaskFunc]: ...
52-
def __init__(
53-
self, initdata: tuple[bytes, Literal["function", "script"]], shared: Mapping[str, object] | None = None
54-
) -> None: ... # type: ignore[override]
35+
def prepare(cls, initializer: Callable[[], object], initargs: tuple[()]) -> tuple[Callable[[], Self], _TaskFunc]: ...
36+
def __init__(self, initdata: _Task) -> None: ...
5537
def __del__(self) -> None: ...
56-
def run(self, task: _Task) -> None: ... # type: ignore[override]
38+
def run(self, task: _Task) -> None: ... # type: ignore[override]
5739

5840
class BrokenInterpreterPool(BrokenThreadPool): ...
5941

6042
class InterpreterPoolExecutor(ThreadPoolExecutor):
6143
BROKEN: type[BrokenInterpreterPool]
6244

63-
@overload # type: ignore[override]
45+
@overload # type: ignore[override]
6446
@classmethod
6547
def prepare_context(
66-
cls, initializer: Callable[[], object], initargs: tuple[()], shared: Mapping[str, object]
48+
cls, initializer: Callable[[], object], initargs: tuple[()]
6749
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
68-
@overload # type: ignore[override]
50+
@overload
6951
@classmethod
7052
def prepare_context(
71-
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]], shared: Mapping[str, object]
53+
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
7254
) -> tuple[Callable[[], WorkerContext], _TaskFunc]: ...
7355
@overload
7456
def __init__(
@@ -77,7 +59,6 @@ if sys.version_info >= (3, 14):
7759
thread_name_prefix: str = "",
7860
initializer: Callable[[], object] | None = None,
7961
initargs: tuple[()] = (),
80-
shared: Mapping[str, object] | None = None,
8162
) -> None: ...
8263
@overload
8364
def __init__(
@@ -87,7 +68,6 @@ if sys.version_info >= (3, 14):
8768
*,
8869
initializer: Callable[[Unpack[_Ts]], object],
8970
initargs: tuple[Unpack[_Ts]],
90-
shared: Mapping[str, object] | None = None,
9171
) -> None: ...
9272
@overload
9373
def __init__(
@@ -96,5 +76,4 @@ if sys.version_info >= (3, 14):
9676
thread_name_prefix: str,
9777
initializer: Callable[[Unpack[_Ts]], object],
9878
initargs: tuple[Unpack[_Ts]],
99-
shared: Mapping[str, object] | None = None,
10079
) -> None: ...

0 commit comments

Comments
 (0)