Skip to content

Fix: add missing multiprocessing.popen_spawn_win32 #8428

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 9 commits into from
Jul 29, 2022
30 changes: 30 additions & 0 deletions stdlib/multiprocessing/popen_spawn_win32.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
6 changes: 4 additions & 2 deletions stdlib/multiprocessing/reduction.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
3 changes: 3 additions & 0 deletions tests/stubtest_allowlists/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_]+
Expand Down
3 changes: 3 additions & 0 deletions tests/stubtest_allowlists/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down