class documentation
class SharedStateManager(ABC): (source)
Known subclasses: temporalio.worker._activity._MultiprocessingSharedStateManager
Constructor: SharedStateManager.create_from_multiprocessing(mgr, queue_poller_executor)
Base class for a shared state manager providing cross-process-safe primitives for use by activity executors.
Cross-worker use of the shared state manager is encouraged.
create_from_multiprocessing
provides the commonly used
implementation.
Static Method | create |
Create a shared state manager from a multiprocessing manager. |
Method | new |
Create a threading.Event that can be used across processes. |
Async Method | register |
Register a heartbeat function. |
Async Method | unregister |
Unregisters a previously registered heartbeater for the task token. This should also flush any pending heartbeats. |
@staticmethod
def create_from_multiprocessing(mgr:
def create_from_multiprocessing(mgr:
multiprocessing.managers.SyncManager
, queue_poller_executor: Optional[ concurrent.futures.Executor]
= None) -> SharedStateManager
:
(source)
¶
Create a shared state manager from a multiprocessing manager.
Parameters | |
mgr:multiprocessing.managers.SyncManager | Sync manager to create primitives from. This is usually
multiprocessing.Manager . |
queueOptional[ | The executor used when running the
synchronous heartbeat queue poller. This should be a
concurrent.futures.ThreadPoolExecutor . If unset, a
thread pool executor is created with max-workers of 1. |
Returns | |
SharedStateManager | The shared state manager. |
@abstractmethod
async def register_heartbeater(self, task_token:
async def register_heartbeater(self, task_token:
bytes
, heartbeat: Callable[ ..., None]
) -> SharedHeartbeatSender
:
(source)
¶
Register a heartbeat function.
Parameters | |
taskbytes | Unique task token for the heartbeater. |
heartbeat:Callable[ | Function that should be called when the resulting sender is sent a heartbeat. |
Returns | |
SharedHeartbeatSender | A sender that can be pickled for use in another process. |