@@ -4,14 +4,18 @@ from collections.abc import Callable, Iterable, Sequence
4
4
from ctypes import _CData
5
5
from logging import Logger
6
6
from multiprocessing import popen_fork , popen_forkserver , popen_spawn_posix , popen_spawn_win32 , queues , synchronize
7
- from multiprocessing .connection import _ConnectionBase
8
7
from multiprocessing .managers import SyncManager
9
8
from multiprocessing .pool import Pool as _Pool
10
9
from multiprocessing .process import BaseProcess
11
10
from multiprocessing .sharedctypes import SynchronizedArray , SynchronizedBase
12
11
from typing import Any , ClassVar , TypeVar , overload
13
12
from typing_extensions import Literal , TypeAlias
14
13
14
+ if sys .platform != "win32" :
15
+ from multiprocessing .connection import Connection
16
+ else :
17
+ from multiprocessing .connection import PipeConnection
18
+
15
19
if sys .version_info >= (3 , 8 ):
16
20
__all__ = ()
17
21
else :
@@ -43,7 +47,15 @@ class BaseContext:
43
47
def active_children () -> list [BaseProcess ]: ...
44
48
def cpu_count (self ) -> int : ...
45
49
def Manager (self ) -> SyncManager : ...
46
- def Pipe (self , duplex : bool = ...) -> tuple [_ConnectionBase , _ConnectionBase ]: ...
50
+
51
+ # N.B. Keep this in sync with multiprocessing.connection.Pipe.
52
+ # _ConnectionBase is the common base class of Connection and PipeConnection
53
+ # and can be used in cross-platform code.
54
+ if sys .platform != "win32" :
55
+ def Pipe (self , duplex : bool = ...) -> tuple [Connection , Connection ]: ...
56
+ else :
57
+ def Pipe (self , duplex : bool = ...) -> tuple [PipeConnection , PipeConnection ]: ...
58
+
47
59
def Barrier (
48
60
self , parties : int , action : Callable [..., object ] | None = ..., timeout : float | None = ...
49
61
) -> synchronize .Barrier : ...
0 commit comments