Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
170 changes: 170 additions & 0 deletions billiard-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,2 +1,172 @@
from collections.abc import Callable, Iterable
from ctypes import Array as _CTypesArray
from ctypes import _CData
from logging import Logger
from multiprocessing import (
AuthenticationError as AuthenticationError,
)
from multiprocessing import (
BufferTooShort as BufferTooShort,
)
from multiprocessing import (
ProcessError as ProcessError,
)
from multiprocessing import (
TimeoutError as TimeoutError,
)
from multiprocessing.context import BaseContext
from multiprocessing.managers import SyncManager
from multiprocessing.queues import (
JoinableQueue as _JoinableQueue,
)
from multiprocessing.queues import (
Queue as _Queue,
)
from multiprocessing.queues import (
SimpleQueue as _SimpleQueue,
)
from multiprocessing.sharedctypes import SynchronizedBase
from multiprocessing.synchronize import (
Barrier as _Barrier,
)
from multiprocessing.synchronize import (
BoundedSemaphore as _BoundedSemaphore,
)
from multiprocessing.synchronize import (
Condition as _Condition,
)
from multiprocessing.synchronize import (
Event as _Event,
)
from multiprocessing.synchronize import (
Lock as _Lock,
)
from multiprocessing.synchronize import (
RLock as _RLock,
)
from multiprocessing.synchronize import (
Semaphore as _Semaphore,
)
from typing import Any

from billiard import einfo as einfo
from billiard import exceptions as exceptions
from billiard.connection import Connection
from billiard.context import Process as Process
from billiard.exceptions import (
SoftTimeLimitExceeded as SoftTimeLimitExceeded,
)
from billiard.exceptions import (
TimeLimitExceeded as TimeLimitExceeded,
)
from billiard.exceptions import (
WorkerLostError as WorkerLostError,
)
from billiard.pool import Pool as _Pool
from billiard.process import active_children as active_children
from billiard.process import current_process as current_process

__all__ = [
"Array",
"AuthenticationError",
"Barrier",
"BoundedSemaphore",
"BufferTooShort",
"Condition",
"Event",
"JoinableQueue",
"Lock",
"Manager",
"Pipe",
"Pool",
"Process",
"ProcessError",
"Queue",
"RLock",
"RawArray",
"RawValue",
"Semaphore",
"SimpleQueue",
"SoftTimeLimitExceeded",
"TimeLimitExceeded",
"TimeoutError",
"Value",
"WorkerLostError",
"active_children",
"allow_connection_pickling",
"cpu_count",
"current_process",
"forking_enable",
"forking_is_enabled",
"freeze_support",
"get_all_start_methods",
"get_context",
"get_logger",
"get_start_method",
"log_to_stderr",
"set_executable",
"set_forkserver_preload",
"set_start_method",
]

def Array(
typecode_or_type: str | type[_CData],
size_or_initializer: int | Iterable[Any],
*args: Any,
**kwargs: Any,
) -> _CTypesArray[Any]: ...
def Barrier(
parties: int, action: Callable[[], Any] | None = ..., timeout: float | None = ...
) -> _Barrier: ...
def BoundedSemaphore(value: int = ...) -> _BoundedSemaphore: ...
def Condition(lock: _Lock | _RLock | None = ...) -> _Condition: ...
def Event() -> _Event: ...
def JoinableQueue(maxsize: int = ...) -> _JoinableQueue[Any]: ...
def Lock() -> _Lock: ...
def Manager() -> SyncManager: ...
def Pipe(
duplex: bool = ..., rnonblock: bool = ..., wnonblock: bool = ...
) -> tuple[Connection, Connection]: ...
def Pool(
processes: int | None = ...,
initializer: Callable[..., Any] | None = ...,
initargs: tuple[Any, ...] = ...,
maxtasksperchild: int | None = ...,
timeout: float | None = ...,
soft_timeout: float | None = ...,
lost_worker_timeout: float | None = ...,
max_restarts: int | None = ...,
max_restart_freq: int = ...,
on_process_up: Callable[..., Any] | None = ...,
on_process_down: Callable[..., Any] | None = ...,
on_timeout_set: Callable[..., Any] | None = ...,
on_timeout_cancel: Callable[..., Any] | None = ...,
threads: bool = ...,
semaphore: Any | None = ...,
putlocks: bool = ...,
allow_restart: bool = ...,
) -> _Pool: ...
def Queue(maxsize: int = ...) -> _Queue[Any]: ...
def RLock() -> _RLock: ...
def RawArray(
typecode_or_type: str | type[_CData], size_or_initializer: int | Iterable[Any]
) -> _CTypesArray[Any]: ...
def RawValue(typecode_or_type: str | type[_CData], *args: Any) -> Any: ...
def Semaphore(value: int = ...) -> _Semaphore: ...
def SimpleQueue() -> _SimpleQueue[Any]: ...
def Value(
typecode_or_type: str | type[_CData], *args: Any, **kwargs: Any
) -> SynchronizedBase[Any]: ...
def allow_connection_pickling() -> None: ...
def cpu_count() -> int: ...
def forking_enable(value: bool) -> None: ...
def forking_is_enabled() -> bool: ...
def freeze_support() -> None: ...
def get_all_start_methods() -> list[str]: ...
def get_context(method: str | None = ...) -> BaseContext: ...
def get_logger() -> Logger: ...
def get_start_method(allow_none: bool = ...) -> str | None: ...
def log_to_stderr(level: int | None = ...) -> Logger: ...
def set_executable(executable: str) -> None: ...
def set_forkserver_preload(module_names: list[str]) -> None: ...
def set_start_method(method: str, force: bool = ...) -> None: ...
2 changes: 2 additions & 0 deletions billiard-stubs/allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# billiard.popen_spawn_win32 is Windows-only and cannot be tested on Linux
billiard.popen_spawn_win32
5 changes: 4 additions & 1 deletion billiard-stubs/common.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import pickle
from signal import _HANDLER, _SIGNUM, Signals
from typing import Any

from billiard.exceptions import RestartFreqExceeded as _RestartFreqExceeded

pickle_load = pickle.load
pickle_loads = pickle.loads

def pickle_loads(s: Any, load: Any = ...) -> Any: ...

SIGMAP: dict[Signals, str]
TERM_SIGNAL: Signals
TERM_SIGNAME: str
Expand Down
12 changes: 7 additions & 5 deletions billiard-stubs/compat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ from typing import SupportsInt, TypeAlias, TypeVar

from _typeshed import FileDescriptorLike, ReadableBuffer, StrOrBytesPath

FILENO_ERRORS: tuple[Exception]
FILENO_ERRORS: tuple[
type[AttributeError], type[ValueError], type[io.UnsupportedOperation]
]
__write__ = os.write

def send_offset(fd: int, buf: ReadableBuffer, offset: int) -> int: ...

fsencode = os.fsencode
fsdecode = os.fsdecode

MaybeFileNo: TypeAlias = numbers.Integral | io.IOBase
_MaybeFileNo: TypeAlias = numbers.Integral | io.IOBase

def maybe_fileno(f: MaybeFileNo) -> numbers.Integral: ...
def maybe_fileno(f: _MaybeFileNo) -> numbers.Integral: ...
def get_fdmax(default: int | None = ...) -> int | None: ...

_T = TypeVar("_T")
Expand All @@ -25,10 +27,10 @@ def uniq(it: Sequence[_T]) -> Iterator[_T]: ...

closerange = os.closerange

def close_open_fds(keep: Sequence[MaybeFileNo] | None = ...) -> None: ...
def close_open_fds(keep: Sequence[_MaybeFileNo] | None = ...) -> None: ...
def get_errno(exc: Exception | None) -> int: ...
def spawnv_passfds(
path: StrOrBytesPath, args: os._ExecVArgs, passfds: Sequence[MaybeFileNo]
path: StrOrBytesPath, args: os._ExecVArgs, passfds: Sequence[_MaybeFileNo]
) -> int: ...
def isblocking(handle: FileDescriptorLike) -> bool: ...
def setblocking(handle: FileDescriptorLike, blocking: bool) -> None: ...
Expand Down
84 changes: 80 additions & 4 deletions billiard-stubs/connection.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,99 @@
__all__ = ["Listener"]
from collections.abc import Callable, Iterable
from types import TracebackType
from typing import Any

class _SocketContainer: ...
from typing_extensions import Self

__all__ = ["Client", "Listener", "Pipe", "wait"]

from socket import socket

class _SocketContainer:
def __init__(self, sock: socket) -> None: ...

class _ConnectionBase:
def __init__(
self, handle: int, readable: bool = ..., writable: bool = ...
) -> None: ...
def __del__(self) -> None: ...
def close(self) -> None: ...
def send(self, obj: Any) -> None: ...
def recv(self) -> Any: ...
def poll(self, timeout: float = ...) -> bool: ...
def send_bytes(
self, buf: bytes, offset: int = ..., size: int | None = ...
) -> None: ...
def recv_bytes(self, maxlength: int | None = ...) -> bytes: ...
def recv_bytes_into(self, buf: bytearray, offset: int = ...) -> int: ...
def send_offset(self, buf: bytes, offset: int) -> None: ...
def setblocking(self, blocking: bool) -> None: ...
@property
def closed(self) -> bool: ...
@property
def readable(self) -> bool: ...
@property
def writable(self) -> bool: ...
def fileno(self) -> int: ...
def __enter__(self) -> Self: ...
def __exit__(
self,
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
exc_tb: TracebackType | None,
) -> None: ...

class PipeConnection(_ConnectionBase): ...
class Connection(_ConnectionBase): ...

class Listener:
def __init__(
self,
address: str | tuple[str, int] | None = ...,
family: str | None = ...,
backlog: int = ...,
authkey: bytes | None = ...,
) -> None: ...
def accept(self) -> Connection: ...
def close(self) -> None: ...
@property
def address(self) -> str | tuple[str, int]: ...
@property
def last_accepted(self) -> str | tuple[str, int] | None: ...
def __enter__(self) -> Self: ...
def __exit__(
self,
exc_type: type[BaseException] | None,
exc_value: BaseException | None,
exc_tb: TracebackType | None,
) -> None: ...

class SocketListener:
def __init__(
self,
address: str | tuple[str, int],
family: str,
backlog: int = ...,
) -> None: ...
def accept(self) -> Connection: ...
def close(self) -> None: ...

class ConnectionWrapper: ...
class ConnectionWrapper:
def __init__(
self,
conn: Connection,
dumps: Callable[..., bytes],
loads: Callable[..., Any],
) -> None: ...
def send(self, obj: Any) -> None: ...
def recv(self) -> Any: ...

class XmlListener(Listener): ...

def Client(
address: str | tuple[str, int],
family: str | None = ...,
authkey: bytes | None = ...,
) -> Connection: ...
def Pipe(
duplex: bool = ..., rnonblock: bool = ..., wnonblock: bool = ...
) -> tuple[Connection, Connection]: ...
def wait(object_list: Iterable[Any], timeout: float | None = ...) -> list[Any]: ...
Loading
Loading