Skip to main content

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.4.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio_actors-0.1.4-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file aio_actors-0.1.4.tar.gz.

File metadata

  • Download URL: aio_actors-0.1.4.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.26

File hashes

Hashes for aio_actors-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7750276fe21e780bce21a2adb0227650544f0016e63e5ab9c200651feae5cd81
MD5 57cbc829e9d27e1d0a4b8621aefaff43
BLAKE2b-256 7a963482aaa336d097c0cc75c8f79921d8b43f158427563c42ab1ccb70c22df7

See more details on using hashes here.

File details

Details for the file aio_actors-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: aio_actors-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.26

File hashes

Hashes for aio_actors-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 66efbc488f50803726b7101cee57bbf0bb0b959f80b0c36e472e9f0d470d9279
MD5 7d67b8467f344bba2bb03a1f220d722a
BLAKE2b-256 2f15dc63e90abf922826d644f2a0aee277ce72a28ad3dcac22361ef7e90a1d04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page