diff --git a/stdlib/multiprocessing/popen_spawn_win32.pyi b/stdlib/multiprocessing/popen_spawn_win32.pyi new file mode 100644 index 000000000000..f5cb0a6c4844 --- /dev/null +++ b/stdlib/multiprocessing/popen_spawn_win32.pyi @@ -0,0 +1,30 @@ +import sys +from multiprocessing.process import BaseProcess +from typing import ClassVar + +from .util import Finalize + +if sys.platform == "win32": + __all__ = ["Popen"] + + TERMINATE: int + WINEXE: bool + WINSERVICE: bool + WINENV: bool + + class Popen: + finalizer: Finalize + method: ClassVar[str] + pid: int + returncode: int | None + sentinel: int + + def __init__(self, process_obj: BaseProcess) -> None: ... + def duplicate_for_child(self, handle: int) -> int: ... + def wait(self, timeout: float | None = ...) -> int | None: ... + def poll(self) -> int | None: ... + def terminate(self) -> None: ... + + kill = terminate + + def close(self) -> None: ... diff --git a/stdlib/multiprocessing/reduction.pyi b/stdlib/multiprocessing/reduction.pyi index 5ddfcbe84647..a22c16828780 100644 --- a/stdlib/multiprocessing/reduction.pyi +++ b/stdlib/multiprocessing/reduction.pyi @@ -27,9 +27,11 @@ def dump(obj, file, protocol: Any | None = ...) -> None: ... if sys.platform == "win32": if sys.version_info >= (3, 8): - def duplicate(handle, target_process: Any | None = ..., inheritable: bool = ..., *, source_process: Any | None = ...): ... + def duplicate( + handle: int, target_process: int | None = ..., inheritable: bool = ..., *, source_process: int | None = ... + ) -> int: ... else: - def duplicate(handle, target_process: Any | None = ..., inheritable: bool = ...): ... + def duplicate(handle: int, target_process: int | None = ..., inheritable: bool = ...) -> int: ... def steal_handle(source_pid, handle): ... def send_handle(conn, handle, destination_pid) -> None: ... diff --git a/tests/stubtest_allowlists/darwin.txt b/tests/stubtest_allowlists/darwin.txt index eb29023ee3da..6c4349dd4ff5 100644 --- a/tests/stubtest_allowlists/darwin.txt +++ b/tests/stubtest_allowlists/darwin.txt @@ -48,6 +48,9 @@ winsound ossaudiodev spwd +# multiprocessing.popen_spawn_win32 exists on Darwin but fail to import +multiprocessing.popen_spawn_win32 + # Platform differences that cannot be captured by the type system os.SCHED_[A-Z_]+ posix.SCHED_[A-Z_]+ diff --git a/tests/stubtest_allowlists/linux.txt b/tests/stubtest_allowlists/linux.txt index c38a121f0b5b..91ea20cf7418 100644 --- a/tests/stubtest_allowlists/linux.txt +++ b/tests/stubtest_allowlists/linux.txt @@ -37,6 +37,9 @@ msvcrt winreg winsound +# multiprocessing.popen_spawn_win32 exists on Linux but fail to import +multiprocessing.popen_spawn_win32 + # Aliases for OSError posix.error.characters_written resource.error.characters_written