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.2.tar.gz (9.0 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.2-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aio_actors-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a72527564f7d05570e18e31d35c7bb4d774ae5e3e64a301949c1188d13888faa
MD5 ae3204c3b5b5a5fe57fc2ef6b3f9352c
BLAKE2b-256 758a6785cf030f80a1d69a5fb67b3c27c97af256c27d05dfbc3360925573e177

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aio_actors-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 167ebd7c87990acde22082c0623339ea02731243cc3e2adc52f1c69310725b6a
MD5 c75ab12c5d5d76875a0160184305b508
BLAKE2b-256 3d93539a975c7aaea50f7ed759ba44a0c41ba0154751bd0d4a77beb85616a736

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