Skip to content

Update ThreadPoolExecutor attributes for Python 3.14 #14263

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/@tests/test_cases/check_concurrent_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def check_interpreter_pool_executor() -> None:
worker_context = context[0]()
assert_type(worker_context, concurrent.futures.interpreter.WorkerContext)
resolve_task = context[1]
# Function should enfore that the arguments are correct.
# Function should enforce that the arguments are correct.
res = resolve_task(_initializer, 1)
assert_type(res, tuple[bytes, Literal["function"]])
# When the function is a script, the arguments should be a string.
Expand Down
12 changes: 8 additions & 4 deletions stdlib/concurrent/futures/thread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,25 @@ class ThreadPoolExecutor(Executor):
_shutdown: bool
_shutdown_lock: Lock
_thread_name_prefix: str | None
_initializer: Callable[..., None] | None
_initargs: tuple[Any, ...]
if sys.version_info >= (3, 14):
_create_worker_context: Callable[[], WorkerContext]
_resolve_work_item_task: _ResolveTaskFunc
else:
_initializer: Callable[..., None] | None
_initargs: tuple[Any, ...]
_work_queue: queue.SimpleQueue[_WorkItem[Any]]

if sys.version_info >= (3, 14):
@overload
@classmethod
def prepare_context(
cls, initializer: Callable[[], object], initargs: tuple[()]
) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
) -> tuple[Callable[[], WorkerContext], _ResolveTaskFunc]: ...
@overload
@classmethod
def prepare_context(
cls, initializer: Callable[[Unpack[_Ts]], object], initargs: tuple[Unpack[_Ts]]
) -> tuple[Callable[[], Self], _ResolveTaskFunc]: ...
) -> tuple[Callable[[], WorkerContext], _ResolveTaskFunc]: ...

@overload
def __init__(
Expand Down