Simple library for building actors in asyncio.
Project description
Async IO Actors
A simple library for building actors in asyncio.
Installation
pip install aio-actors
Usage
from aio_actors import Actor
class MyActor(Actor[str]):
async def handle_message(self, message: str) -> None:
print(f"{self.__class__.__name__}: message:{message}")
class MySecondActor(Actor[str]):
def __init__(self, first_actor: MyActor) -> None:
super().__init__()
self._first_actor = first_actor
async def handle_message(self, message: str) -> None:
print(f"{self.__class__.__name__}: message:{message}")
await self._first_actor.send_message(message + " from second actor")
async def main():
actor = MyActor()
await actor.start()
second_actor = MySecondActor(actor)
await second_actor.start()
for i in range(10):
await second_actor.send_message(f"aio-actors is awesome - {i}")
await asyncio.sleep(1)
await actor.shutdown()
await second_actor.shutdown()
if __name__ == "__main__":
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aio_actors-0.1.0.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aio_actors-0.1.0.tar.gz.
File metadata
- Download URL: aio_actors-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3893a7fcf998278a5084ce48076ae7baa59fb21cec8757e57274dd60f686f7ce
|
|
| MD5 |
2c5572f8e51ffc1eb87241b4b88b2daf
|
|
| BLAKE2b-256 |
6867300b58809ea829826c5083bd795f3e5ecf82d24e45b183fa8aef3adf2896
|
File details
Details for the file aio_actors-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aio_actors-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f2e1c6c8c9e96f5edbe3d5b12bd742b54ea37ce4c992f6bd721441e6a91d8af
|
|
| MD5 |
d8121e59514c8404781f718fe948f4a6
|
|
| BLAKE2b-256 |
54151a9e91f5eb5133148a3e40e06b7888a2c7c01ea40afcbcd3d34d73113f87
|