@@ -4,6 +4,7 @@ from logging import Logger
4
4
import multiprocessing
5
5
from multiprocessing import synchronize
6
6
from multiprocessing import queues
7
+ from multiprocessing .process import BaseProcess
7
8
import sys
8
9
from typing import Any , Callable , Iterable , Optional , List , Mapping , Sequence , Type , Union
9
10
@@ -27,9 +28,12 @@ class BaseContext(object):
27
28
# multiprocessing.*, so the signatures should be identical (modulo self).
28
29
29
30
@staticmethod
30
- def current_process () -> multiprocessing .Process : ...
31
+ def current_process () -> BaseProcess : ...
32
+ if sys .version_info >= (3 , 8 ):
33
+ @staticmethod
34
+ def parent_process () -> Optional [BaseProcess ]: ...
31
35
@staticmethod
32
- def active_children () -> List [multiprocessing . Process ]: ...
36
+ def active_children () -> List [BaseProcess ]: ...
33
37
def cpu_count (self ) -> int : ...
34
38
# TODO: change return to SyncManager once a stub exists in multiprocessing.managers
35
39
def Manager (self ) -> Any : ...
@@ -59,16 +63,6 @@ class BaseContext(object):
59
63
initargs : Iterable [Any ] = ...,
60
64
maxtasksperchild : Optional [int ] = ...
61
65
) -> multiprocessing .pool .Pool : ...
62
- def Process (
63
- self ,
64
- group : Any = ...,
65
- target : Optional [Callable [..., Any ]] = ...,
66
- name : Optional [str ] = ...,
67
- args : Iterable [Any ] = ...,
68
- kwargs : Mapping [Any , Any ] = ...,
69
- * ,
70
- daemon : Optional [bool ] = ...
71
- ) -> multiprocessing .Process : ...
72
66
# TODO: typecode_or_type param is a ctype with a base class of _SimpleCData or array.typecode Need to figure out
73
67
# how to handle the ctype
74
68
# TODO: change return to RawValue once a stub exists in multiprocessing.sharedctypes
@@ -104,46 +98,42 @@ class BaseContext(object):
104
98
def set_forkserver_preload (self , module_names : List [str ]) -> None : ...
105
99
def get_context (self , method : Optional [str ] = ...) -> BaseContext : ...
106
100
def get_start_method (self , allow_none : bool = ...) -> str : ...
107
- def set_start_method (self , method : Optional [str ] = ...) -> None : ...
101
+ def set_start_method (self , method : Optional [str ], force : bool = ...) -> None : ...
108
102
@property
109
103
def reducer (self ) -> str : ...
110
104
@reducer .setter
111
105
def reducer (self , reduction : str ) -> None : ...
112
106
def _check_available (self ) -> None : ...
113
107
114
- class Process (object ):
108
+ class Process (BaseProcess ):
115
109
_start_method : Optional [str ]
116
110
@staticmethod
117
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
118
- def _Popen (process_obj : Any ) -> DefaultContext : ...
111
+ def _Popen (process_obj : BaseProcess ) -> DefaultContext : ...
119
112
120
- class DefaultContext (object ):
113
+ class DefaultContext (BaseContext ):
121
114
Process : Type [multiprocessing .Process ]
122
115
123
116
def __init__ (self , context : BaseContext ) -> None : ...
124
117
def get_context (self , method : Optional [str ] = ...) -> BaseContext : ...
125
- def set_start_method (self , method : str , force : bool = ...) -> None : ...
118
+ def set_start_method (self , method : Optional [ str ] , force : bool = ...) -> None : ...
126
119
def get_start_method (self , allow_none : bool = ...) -> str : ...
127
120
def get_all_start_methods (self ) -> List [str ]: ...
128
121
129
122
if sys .platform != 'win32' :
130
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
131
- class ForkProcess (Any ):
123
+ class ForkProcess (BaseProcess ):
132
124
_start_method : str
133
125
@staticmethod
134
- def _Popen (process_obj : Any ) -> Any : ...
126
+ def _Popen (process_obj : BaseProcess ) -> Any : ...
135
127
136
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
137
- class SpawnProcess (Any ):
128
+ class SpawnProcess (BaseProcess ):
138
129
_start_method : str
139
130
@staticmethod
140
- def _Popen (process_obj : Any ) -> SpawnProcess : ...
131
+ def _Popen (process_obj : BaseProcess ) -> SpawnProcess : ...
141
132
142
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
143
- class ForkServerProcess (Any ):
133
+ class ForkServerProcess (BaseProcess ):
144
134
_start_method : str
145
135
@staticmethod
146
- def _Popen (process_obj : Any ) -> Any : ...
136
+ def _Popen (process_obj : BaseProcess ) -> Any : ...
147
137
148
138
class ForkContext (BaseContext ):
149
139
_name : str
@@ -157,20 +147,16 @@ if sys.platform != 'win32':
157
147
_name : str
158
148
Process : Type [ForkServerProcess ]
159
149
else :
160
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
161
- class SpawnProcess (Any ):
150
+ class SpawnProcess (BaseProcess ):
162
151
_start_method : str
163
152
@staticmethod
164
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
165
- def _Popen (process_obj : Process ) -> Any : ...
153
+ def _Popen (process_obj : BaseProcess ) -> Any : ...
166
154
167
155
class SpawnContext (BaseContext ):
168
156
_name : str
169
157
Process : Type [SpawnProcess ]
170
158
171
159
def _force_start_method (method : str ) -> None : ...
172
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
173
160
def get_spawning_popen () -> Optional [Any ]: ...
174
- # TODO: type should be BaseProcess once a stub in multiprocessing.process exists
175
161
def set_spawning_popen (popen : Any ) -> None : ...
176
162
def assert_spawning (obj : Any ) -> None : ...
0 commit comments