Make multiprocessing pipes generic (#11137)

This commit is contained in:
Avasam
2024-10-01 21:11:42 -04:00
committed by GitHub
parent 44aa63330b
commit bdb5b52d50
6 changed files with 72 additions and 27 deletions

View File

@@ -47,10 +47,13 @@ class BaseContext:
# N.B. Keep this in sync with multiprocessing.connection.Pipe.
# _ConnectionBase is the common base class of Connection and PipeConnection
# and can be used in cross-platform code.
#
# The two connections should have the same generic types but inverted (Connection[_T1, _T2], Connection[_T2, _T1]).
# However, TypeVars scoped entirely within a return annotation is unspecified in the spec.
if sys.platform != "win32":
def Pipe(self, duplex: bool = True) -> tuple[Connection, Connection]: ...
def Pipe(self, duplex: bool = True) -> tuple[Connection[Any, Any], Connection[Any, Any]]: ...
else:
def Pipe(self, duplex: bool = True) -> tuple[PipeConnection, PipeConnection]: ...
def Pipe(self, duplex: bool = True) -> tuple[PipeConnection[Any, Any], PipeConnection[Any, Any]]: ...
def Barrier(
self, parties: int, action: Callable[..., object] | None = None, timeout: float | None = None