Add more multiprocessing function stubs#1435
Conversation
This target issue python#1422 but also other related functions. The functions are those that cpython/Lib/multiprocessing/__init__.py is getting from DefaultContext(BaseContext) and listed in https://docs.python.org/3.6/library/multiprocessing.html#miscellaneous.
|
|
||
| # ----- multiprocessing function stubs ----- | ||
| def active_children() -> List[Process]: ... | ||
| def allow_connection_pickling() -> None: ... |
There was a problem hiding this comment.
This is undocumented and apparently does nothing in 3.6. I suppose there's little harm in including it though.
There was a problem hiding this comment.
OK, I'm keeping it then.
| def get_all_start_methods() -> List[str]: ... | ||
| def get_context(method: Optional[str] = ...) -> BaseContext: ... | ||
| def get_logger() -> Logger: ... | ||
| def get_start_method(allow_none: Optional[bool] = ...) -> str: ... |
There was a problem hiding this comment.
This one (as well as get_all_start_methods and get_context) doesn't exist in Python 2.
Also, judging from the documentation allow_none should just be a bool in Python 3, and the return type should be Optional[str].
| def get_context(method: Optional[str] = ...) -> BaseContext: ... | ||
| def get_logger() -> Logger: ... | ||
| def get_start_method(allow_none: Optional[bool] = ...) -> str: ... | ||
| def log_to_stderr(level: Optional[str] = ...) -> Logger: ... |
There was a problem hiding this comment.
I think the level can also be an int, since it just gets passed to setLevel in logging.
There was a problem hiding this comment.
Thanks. Moving level to Optional[Union[str, int]].
| def get_start_method(allow_none: Optional[bool] = ...) -> str: ... | ||
| def log_to_stderr(level: Optional[str] = ...) -> Logger: ... | ||
| def Manager() -> SyncManager: ... | ||
| def set_executable(executable: str) -> None: ... |
There was a problem hiding this comment.
This one only exists on Windows, and sometimes on Unix after 3.4.
| def Manager() -> SyncManager: ... | ||
| def set_executable(executable: str) -> None: ... | ||
| def set_forkserver_preload(module_names: List[str]) -> None: ... | ||
| def set_start_method(method: Optional[str] = ...) -> None: ... |
There was a problem hiding this comment.
Only after 3.4, and it doesn't look like the method is Optional.
There is also an undocumented force: bool = ... argument.
There was a problem hiding this comment.
Thanks! On the one hand, it seems that method argument is optional and the undocumented force one is not present just in set_start_method of BaseContext in 3.4. On the other hand, it is overridden (with method not optional and the force optional) in DefaultContext, which seems to contain the imported method from __init__.py. Anyway, this is solved >=3.5 and both the latter signature.
Should stub for set_start_method of BaseContext in multiprocessing/context.pyi (line 94) be corrected with these changes? I mean to be like set_start_method of DefaultContext but for >=3.5.
* python/master: Added stub for toaiff module (python#1455) Added stub for user module (python#1454) Add more multiprocessing function stubs (python#1435) PyYaml: uncomment commented out imports and add missing classmethod decorators (python#1439) Allow `os.readlink` to accept path-like objects (python#1441) Support named attributes in `os.uname()` result (python#1445) Fix signature for slite3.fetchmany (python#1444) Add __name__ field to MethodType (python#1442) Add TypedDict total argument (python#1443)
This target issue #1422 but also other related functions. The functions are those that multiprocessing init is inserting in globals from context.DefaultContext(BaseContext) and listed in the multiprocessing docs.