mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Add type stubs for multiprocessing.Manager() (#1270)
* Use Dict/List types and _Namespace alias * Use TypeVar definitions for mapping/sequence stubs
This commit is contained in:
committed by
Jelle Zijlstra
parent
b6d08b81a3
commit
54408054cc
@@ -3,6 +3,7 @@
|
||||
from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List
|
||||
|
||||
from multiprocessing.context import BaseContext
|
||||
from multiprocessing.managers import SyncManager
|
||||
from multiprocessing.process import current_process as current_process
|
||||
|
||||
class Lock():
|
||||
@@ -105,3 +106,4 @@ class Value():
|
||||
# ----- multiprocessing function stubs -----
|
||||
def cpu_count() -> int: ...
|
||||
def freeze_support() -> None: ...
|
||||
def Manager() -> SyncManager: ...
|
||||
|
||||
@@ -2,9 +2,33 @@
|
||||
|
||||
# NOTE: These are incomplete!
|
||||
|
||||
from typing import Any
|
||||
import queue
|
||||
import threading
|
||||
from typing import Any, Dict, List, Mapping, Sequence, TypeVar
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_KT = TypeVar('_KT')
|
||||
_VT = TypeVar('_VT')
|
||||
|
||||
class Namespace: ...
|
||||
|
||||
_Namespace = Namespace
|
||||
|
||||
class BaseManager:
|
||||
def register(self, typeid: str, callable: Any = ...) -> None: ...
|
||||
|
||||
class SyncManager(BaseManager):
|
||||
def BoundedSemaphore(self, value: Any = ...) -> threading.BoundedSemaphore: ...
|
||||
def Condition(self, lock: Any = ...) -> threading.Condition: ...
|
||||
def Event(self) -> threading.Event: ...
|
||||
def Lock(self) -> threading.Lock: ...
|
||||
def Namespace(self) -> _Namespace: ...
|
||||
def Queue(self, maxsize: int = ...) -> queue.Queue: ...
|
||||
def RLock(self) -> threading.RLock: ...
|
||||
def Semaphore(self, value: Any = ...) -> threading.Semaphore: ...
|
||||
def Array(self, typecode: Any, sequence: Sequence[_T]) -> Sequence[_T]: ...
|
||||
def Value(self, typecode: Any, value: _T) -> _T: ...
|
||||
def dict(self, sequence: Mapping[_KT, _VT] = ...) -> Dict[_KT, _VT]: ...
|
||||
def list(self, sequence: Sequence[_T] = ...) -> List[_T]: ...
|
||||
|
||||
class RemoteError(Exception): ...
|
||||
|
||||
Reference in New Issue
Block a user