11import queue
22import sys
33import threading
4- from _typeshed import Incomplete , SupportsKeysAndGetItem , SupportsRichComparison , SupportsRichComparisonT
4+ from _typeshed import SupportsKeysAndGetItem , SupportsRichComparison , SupportsRichComparisonT
55from collections .abc import Callable , Iterable , Iterator , Mapping , MutableMapping , MutableSequence , Sequence
66from types import TracebackType
77from typing import Any , AnyStr , ClassVar , Generic , SupportsIndex , TypeVar , overload
88from typing_extensions import Self , TypeAlias
99
10- from .connection import Connection
10+ from . import pool
11+ from .connection import Connection , _Address
1112from .context import BaseContext
1213from .shared_memory import _SLT , ShareableList as _ShareableList , SharedMemory as _SharedMemory
1314from .util import Finalize as _Finalize
@@ -30,14 +31,14 @@ _Namespace: TypeAlias = Namespace
3031
3132class Token :
3233 typeid : str | bytes | None
33- address : tuple [ str | bytes , int ]
34+ address : _Address | None
3435 id : str | bytes | int | None
35- def __init__ (self , typeid : bytes | str | None , address : tuple [ str | bytes , int ] , id : str | bytes | int | None ) -> None : ...
36+ def __init__ (self , typeid : bytes | str | None , address : _Address | None , id : str | bytes | int | None ) -> None : ...
3637 def __getstate__ (self ) -> tuple [str | bytes | None , tuple [str | bytes , int ], str | bytes | int | None ]: ...
3738 def __setstate__ (self , state : tuple [str | bytes | None , tuple [str | bytes , int ], str | bytes | int | None ]) -> None : ...
3839
3940class BaseProxy :
40- _address_to_local : dict [Any , Any ]
41+ _address_to_local : dict [_Address , Any ]
4142 _mutex : Any
4243 def __init__ (
4344 self ,
@@ -151,22 +152,50 @@ class ListProxy(BaseListProxy[_T]):
151152 if sys .version_info >= (3 , 13 ):
152153 def __class_getitem__ (cls , args : Any , / ) -> Any : ...
153154
155+ # Send is (kind, result)
156+ # Receive is (id, methodname, args, kwds)
157+ _ServerConnection : TypeAlias = Connection [tuple [str , Any ], tuple [str , str , Iterable [Any ], Mapping [str , Any ]]]
158+
154159# Returned by BaseManager.get_server()
155160class Server :
156- address : Any
161+ address : _Address | None
162+ id_to_obj : dict [str , tuple [Any , set [str ], dict [str , str ]]]
163+ fallback_mapping : dict [str , Callable [[_ServerConnection , str , Any ], Any ]]
164+ public : list [str ]
165+ # Registry values are (callable, exposed, method_to_typeid, proxytype)
157166 def __init__ (
158- self , registry : dict [str , tuple [Callable [..., Any ], Any , Any , Any ]], address : Any , authkey : bytes , serializer : str
167+ self ,
168+ registry : dict [str , tuple [Callable [..., Any ], Iterable [str ], dict [str , str ], Any ]],
169+ address : _Address | None ,
170+ authkey : bytes ,
171+ serializer : str ,
159172 ) -> None : ...
160173 def serve_forever (self ) -> None : ...
161- def accept_connection (
162- self , c : Connection [tuple [str , str | None ], tuple [str , str , Iterable [Incomplete ], Mapping [str , Incomplete ]]], name : str
163- ) -> None : ...
174+ def accepter (self ) -> None : ...
175+ if sys .version_info >= (3 , 10 ):
176+ def handle_request (self , conn : _ServerConnection ) -> None : ...
177+ else :
178+ def handle_request (self , c : _ServerConnection ) -> None : ...
179+
180+ def serve_client (self , conn : _ServerConnection ) -> None : ...
181+ def fallback_getvalue (self , conn : _ServerConnection , ident : str , obj : _T ) -> _T : ...
182+ def fallback_str (self , conn : _ServerConnection , ident : str , obj : Any ) -> str : ...
183+ def fallback_repr (self , conn : _ServerConnection , ident : str , obj : Any ) -> str : ...
184+ def dummy (self , c : _ServerConnection ) -> None : ...
185+ def debug_info (self , c : _ServerConnection ) -> str : ...
186+ def number_of_objects (self , c : _ServerConnection ) -> int : ...
187+ def shutdown (self , c : _ServerConnection ) -> None : ...
188+ def create (self , c : _ServerConnection , typeid : str , / , * args : Any , ** kwds : Any ) -> tuple [str , tuple [str , ...]]: ...
189+ def get_methods (self , c : _ServerConnection , token : Token ) -> set [str ]: ...
190+ def accept_connection (self , c : _ServerConnection , name : str ) -> None : ...
191+ def incref (self , c : _ServerConnection , ident : str ) -> None : ...
192+ def decref (self , c : _ServerConnection , ident : str ) -> None : ...
164193
165194class BaseManager :
166195 if sys .version_info >= (3 , 11 ):
167196 def __init__ (
168197 self ,
169- address : Any | None = None ,
198+ address : _Address | None = None ,
170199 authkey : bytes | None = None ,
171200 serializer : str = "pickle" ,
172201 ctx : BaseContext | None = None ,
@@ -176,7 +205,7 @@ class BaseManager:
176205 else :
177206 def __init__ (
178207 self ,
179- address : Any | None = None ,
208+ address : _Address | None = None ,
180209 authkey : bytes | None = None ,
181210 serializer : str = "pickle" ,
182211 ctx : BaseContext | None = None ,
@@ -188,7 +217,7 @@ class BaseManager:
188217 shutdown : _Finalize # only available after start() was called
189218 def join (self , timeout : float | None = None ) -> None : ... # undocumented
190219 @property
191- def address (self ) -> Any : ...
220+ def address (self ) -> _Address | None : ...
192221 @classmethod
193222 def register (
194223 cls ,
@@ -205,14 +234,26 @@ class BaseManager:
205234 ) -> None : ...
206235
207236class SyncManager (BaseManager ):
208- def BoundedSemaphore (self , value : Any = ...) -> threading .BoundedSemaphore : ...
209- def Condition (self , lock : Any = ...) -> threading .Condition : ...
237+ def Barrier (
238+ self , parties : int , action : Callable [[], None ] | None = None , timeout : float | None = None
239+ ) -> threading .Barrier : ...
240+ def BoundedSemaphore (self , value : int = 1 ) -> threading .BoundedSemaphore : ...
241+ def Condition (self , lock : threading .Lock | threading ._RLock | None = None ) -> threading .Condition : ...
210242 def Event (self ) -> threading .Event : ...
211243 def Lock (self ) -> threading .Lock : ...
212244 def Namespace (self ) -> _Namespace : ...
245+ def Pool (
246+ self ,
247+ processes : int | None = None ,
248+ initializer : Callable [..., object ] | None = None ,
249+ initargs : Iterable [Any ] = (),
250+ maxtasksperchild : int | None = None ,
251+ context : Any | None = None ,
252+ ) -> pool .Pool : ...
213253 def Queue (self , maxsize : int = ...) -> queue .Queue [Any ]: ...
254+ def JoinableQueue (self , maxsize : int = ...) -> queue .Queue [Any ]: ...
214255 def RLock (self ) -> threading .RLock : ...
215- def Semaphore (self , value : Any = ... ) -> threading .Semaphore : ...
256+ def Semaphore (self , value : int = 1 ) -> threading .Semaphore : ...
216257 def Array (self , typecode : Any , sequence : Sequence [_T ]) -> Sequence [_T ]: ...
217258 def Value (self , typecode : Any , value : _T ) -> ValueProxy [_T ]: ...
218259 # Overloads are copied from builtins.dict.__init__
@@ -238,7 +279,11 @@ class SyncManager(BaseManager):
238279 def list (self ) -> ListProxy [Any ]: ...
239280
240281class RemoteError (Exception ): ...
241- class SharedMemoryServer (Server ): ...
282+
283+ class SharedMemoryServer (Server ):
284+ def track_segment (self , c : _ServerConnection , segment_name : str ) -> None : ...
285+ def release_segment (self , c : _ServerConnection , segment_name : str ) -> None : ...
286+ def list_segments (self , c : _ServerConnection ) -> list [str ]: ...
242287
243288class SharedMemoryManager (BaseManager ):
244289 def get_server (self ) -> SharedMemoryServer : ...
0 commit comments