def __spawn_watcher(self, address, context) -> PID: watcher_props = from_producer(lambda: EndpointWatcher(address)) watcher = context.spawn(watcher_props) return watcher
def __spawn_witer(self, address, context) -> PID: writer_props = from_producer(lambda: EndpointWatcher(address))\ .with_mailbox_producer(lambda: EndpointWriterMailbox()) writer = context.spawn(writer_props) return writer
from protoactor import actor, context class HelloMessage: def __init__(self, text: str): self.text = text class HelloActor(actor.Actor): async def receive(self, context: context.AbstractContext) -> None: message = context.message if isinstance(message, HelloMessage): print(message.text) if __name__ == "__main__": props = actor.from_producer(lambda: HelloActor()) pid = actor.spawn(props) pid.tell(HelloMessage('Hello World!'))