Skip to main content

asyncactor

AsyncActor is an async Python module that aids in service discovery and “somewhat-leader” election in a heterogenous, sometimes-disconnected network.

AsyncActor can run on top of any reliable broadcast channel. This version includes back-ends for Serf and MQTT.

AsyncActor sends as few packets as possible, thus is well-suited for IoT-related applications with many stations but limited bandwidth.

Theory of operation

Assume that you have a non-lossy network with a bounded latency (let’s assume one second). Assume further that you’d like to know within ten seconds whether your node is still online.

AsyncActor sends one beacon message every seven to nine seconds. The message includes a list of N previous hosts that have transmitted the beacon; the host that’s last in this list will be the next transmitter.

The time slot starting at the seven-second mark is used for random hosts which would like to enter the beacon sending business. This is somewhat likely if the list of hosts is currently smaller than N. The slot at eight seconds is used for the hosts at the end of the list; the last host will send first, but if its beacon is not seen then the next-to-last will send its message, and so on.

The time slot at nine seconds is used for last-resort messages, i.e. any participating host can and will send its beacon message.

Collisions are resolved at the ten-second mark, i.e. the list of messages is ordered deterministically: the winner will announce to its clients that a new slot has started and whether all N host slots are filled.

It uses anyio <https://github.com/agronholm/anyio> as its underlying async framework.

PyPI latest version badge Code coverage badge

Installation

AsyncActor requires a back-end, i.e. either a running Serf agent or a MQTT broker.

To install AsyncActor, run the following command:

$ pip install asyncactor

or alternatively (you really should be using pip though):

$ easy_install asyncactor

or from source:

$ python setup.py install

Getting Started

These examples require a running async loop. Trio <https://github.com/python-trio/trio> is recommended, though asyncio works too.

from asyncactor import client as actor
from somewhere import some_transport

async with some_transport.connect('localhost') as t:
    async with actor(t, prefix=('actor','test')) as client:
        async for client.events as m:
            print(m)

Development

You can run the tests using the following commands:

$ serf agent & # start serf agent
$ mosquitto
$ python3 -mpytest tests

Metadata

Release files for asyncactor 0.28.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncactor 0.28.6
File Size Uploaded Provenance
asyncactor-0.28.6.tar.gz 33.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncactor 0.28.6
File Interpreter ABI Platform
asyncactor-0.28.6-py3-none-any.whl Python 3 none any Details

Total release size: 55.1 kB

Release files / asyncactor-0.28.6.tar.gz

Download URL asyncactor-0.28.6.tar.gz
Size 33.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5cd03bc9e7591983635e929d2edd23f1ecaf12d9591255c0d6dfefb56c17ee30
BLAKE2b-256 checksum
How to use checksums
1f731ae80e1f55944500af379594a5f875af9e071fd15126a9b2382506160d35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / asyncactor-0.28.6-py3-none-any.whl

Download URL asyncactor-0.28.6-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9fc36c71d2765526a062d17ebef08a6cb68c57619ecedd40f0fb0b3d6d6f8b0
BLAKE2b-256 checksum
How to use checksums
f95efc707b548df3bfed6f48924d861f053f15fa792d6a3ce41754998e0d1cc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for asyncactor 0.28.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page