Skip to content

Commit ac86def

Browse files
authored
Simplify multiprocessing.context.{SpawnProcess,SpawnContext} (#8499)
1 parent 892796a commit ac86def

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

stdlib/multiprocessing/context.pyi

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,25 @@ class DefaultContext(BaseContext):
145145

146146
_default_context: DefaultContext
147147

148+
class SpawnProcess(BaseProcess):
149+
_start_method: str
150+
if sys.platform != "win32":
151+
@staticmethod
152+
def _Popen(process_obj: BaseProcess) -> popen_spawn_posix.Popen: ...
153+
else:
154+
@staticmethod
155+
def _Popen(process_obj: BaseProcess) -> popen_spawn_win32.Popen: ...
156+
157+
class SpawnContext(BaseContext):
158+
_name: str
159+
Process: ClassVar[type[SpawnProcess]]
160+
148161
if sys.platform != "win32":
149162
class ForkProcess(BaseProcess):
150163
_start_method: str
151164
@staticmethod
152165
def _Popen(process_obj: BaseProcess) -> popen_fork.Popen: ...
153166

154-
class SpawnProcess(BaseProcess):
155-
_start_method: str
156-
@staticmethod
157-
def _Popen(process_obj: BaseProcess) -> popen_spawn_posix.Popen: ...
158-
159167
class ForkServerProcess(BaseProcess):
160168
_start_method: str
161169
@staticmethod
@@ -165,24 +173,10 @@ if sys.platform != "win32":
165173
_name: str
166174
Process: ClassVar[type[ForkProcess]]
167175

168-
class SpawnContext(BaseContext):
169-
_name: str
170-
Process: ClassVar[type[SpawnProcess]]
171-
172176
class ForkServerContext(BaseContext):
173177
_name: str
174178
Process: ClassVar[type[ForkServerProcess]]
175179

176-
else:
177-
class SpawnProcess(BaseProcess):
178-
_start_method: str
179-
@staticmethod
180-
def _Popen(process_obj: BaseProcess) -> popen_spawn_win32.Popen: ...
181-
182-
class SpawnContext(BaseContext):
183-
_name: str
184-
Process: ClassVar[type[SpawnProcess]]
185-
186180
def _force_start_method(method: str) -> None: ...
187181
def get_spawning_popen() -> Any | None: ...
188182
def set_spawning_popen(popen: Any) -> None: ...

0 commit comments

Comments
 (0)