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

Uploaded Python 3

File details

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

File metadata

  • Download URL: aio_actors-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 783d734e85623d2b4e388404f5202dd6695ed5ea01e2d5e1a34a7ec34f153031
MD5 b5dea4237769c1814d02d3354cf793a1
BLAKE2b-256 41950f6a3ac4a2ce8d32c570651edb61156d21b0e6cbecfdf25a4d5d29cf31dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aio_actors-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c862598b93f0a6108964eb6d45db2bc89ec3acfbd534432f6743544277e1f291
MD5 2ab2541e462f5ad1adeb917f8d7ae4d1
BLAKE2b-256 d4509f87c43e79444cadee8ca8091ef4736ae99acddc592cd42f2df5cd8b748e

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