Skip to content

fix: Add missing multiprocessing.util types #8404

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

Merged
merged 26 commits into from
Jul 27, 2022
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
26d5b1b
fix: Add missing multiprocessing.util types
Jul 26, 2022
c699a3e
fix: remove unnecessary header
Jul 26, 2022
bb46b2e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 26, 2022
2c55d63
fix: incorrect finalize usage
Jul 26, 2022
3383711
fix: correct optional type
Jul 26, 2022
0db9ebb
fix: incorrect default values
Jul 26, 2022
6e43097
fix: remove redundant subclass from object
Jul 26, 2022
564c037
fix: flake8 errors
Jul 26, 2022
274904d
fix: type inaccuracies
Jul 26, 2022
9b948ba
fix: remove function missing at runtime
Jul 26, 2022
4413be4
fix: add args type hint
Jul 26, 2022
e09da48
fix: Any should be object for *args
Jul 26, 2022
31b0bd7
Merge branch 'master' into multiprocessing/util
Jul 27, 2022
bafc3c4
refactor: remove = ... from logging constants
Jul 27, 2022
a472438
fix: remove various private methods
Jul 27, 2022
39069af
fix: remove extraneous default value on global variable
Jul 27, 2022
ecd0768
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2022
aa908d8
fix: remove private function
Jul 27, 2022
3addb5a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2022
7597d4b
fix: remaining feedback items (includes todo comment)
Jul 27, 2022
88ec7d1
refactor: switch object to Incomplete
Jul 27, 2022
1ede3a0
fix: remove todo comment per feedback
Jul 27, 2022
1f76c39
fix: args / kwargs type on multiprocessing.Finalize
Jul 27, 2022
bf9c749
fix: args type and callable return value(s)
Jul 27, 2022
740612b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 27, 2022
4b06dea
Import `SupportsIndex` from `typing_extensions`
AlexWaygood Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions stdlib/multiprocessing/util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import threading
from _typeshed import Incomplete, ReadableBuffer, SupportsTrunc
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
from logging import Logger
from typing import Any, SupportsInt
from typing_extensions import SupportsIndex

__all__ = [
"sub_debug",
"debug",
"info",
"sub_warning",
"get_logger",
"log_to_stderr",
"get_temp_dir",
"register_after_fork",
"is_exiting",
"Finalize",
"ForkAwareThreadLock",
"ForkAwareLocal",
"close_all_fds_except",
"SUBDEBUG",
"SUBWARNING",
]

NOTSET: int
SUBDEBUG: int
DEBUG: int
INFO: int
SUBWARNING: int

LOGGER_NAME: str
DEFAULT_LOGGING_FORMAT: str

def sub_debug(msg: object, *args: object) -> None: ...
def debug(msg: object, *args: object) -> None: ...
def info(msg: object, *args: object) -> None: ...
def sub_warning(msg: object, *args: object) -> None: ...
def get_logger() -> Logger: ...
def log_to_stderr(level: int | None = ...) -> Logger: ...
def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...

abstract_sockets_supported: bool

def get_temp_dir() -> str: ...
def register_after_fork(obj: Incomplete, func: Callable[[Incomplete], object]) -> None: ...

class Finalize:
def __init__(
self,
obj: Incomplete | None,
callback: Callable[..., Incomplete],
args: Sequence[Any] = ...,
kwargs: Mapping[str, Any] | None = ...,
exitpriority: int | None = ...,
) -> None: ...
def __call__(
self,
wr: object = ...,
_finalizer_registry: MutableMapping[Incomplete, Incomplete] = ...,
sub_debug: Callable[..., object] = ...,
getpid: Callable[[], int] = ...,
) -> Incomplete: ...
def cancel(self) -> None: ...
def still_active(self) -> bool: ...

def is_exiting() -> bool: ...

class ForkAwareThreadLock:
acquire: Callable[[bool, float], bool]
release: Callable[[], None]
def __init__(self) -> None: ...
def __enter__(self) -> bool: ...
def __exit__(self, *args: object) -> None: ...

class ForkAwareLocal(threading.local):
def __init__(self) -> None: ...

MAXFD: int

def close_all_fds_except(fds: Iterable[int]) -> None: ...
def spawnv_passfds(
path: bytes,
# args is anything that can be passed to the int constructor
args: Sequence[str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc],
passfds: Sequence[int],
) -> int: ...