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.1.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.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aio_actors-0.1.1.tar.gz
Algorithm Hash digest
SHA256 da72185001b5673221f658dbe4f319ac8a465f922888a1423bb6277031959d99
MD5 45c71abe447de89fe3d0bb0b72e0e04c
BLAKE2b-256 9f328a078577ce7c05541277153d29783c53f5539ca9b499376fe3067caf9e10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aio_actors-0.1.1-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

Hashes for aio_actors-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8cadd6fcf3907a70735fe9ab82e2612020edf39a9ca55389299e2707e1fdba0c
MD5 1b003e91c36db838fbb548d6f0c4a8f9
BLAKE2b-256 15544b0d0da89ea8ad286b70d539175c06ac7335ccaa369a4e2afc8380a8f612

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