-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add more multiprocessing function stubs #1435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
@@ -101,6 +102,16 @@ class Value(): | |||
def __init__(self, typecode_or_type: str, *args: Any, lock: bool = ...) -> None: ... | |||
|
|||
# ----- multiprocessing function stubs ----- | |||
def active_children() -> List[Process]: ... | |||
def allow_connection_pickling() -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Thanks!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Moving level to Optional[Union[str, int]].
def Manager() -> SyncManager: ... | ||
def set_executable(executable: str) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one only exists on Windows, and sometimes on Unix after 3.4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.