Chorus - A simple actor library for Python
Chorus is a Python package that provides a version of the Actor model of concurrency. It is built ontop of Python's built-in threading package and each Actor has its own thread. Actors can send and recieve messges from other actors as well as spawn new Actors.
The package has three layers:
chorus.runtimea minimal API for managing Python threads using the Actor model, roughly based on Erlangs API.chorus.messagingprovides message base classes and request/reply exchanges withtellandask.chorus.dispatchprovides an object-oriented API for sending and receiving messages between actors.
There APIs can be imported directly from the chorus top-level package.
Examples
Here is an example of the chorus.runtime API in action. One actor spawns another and that one echos back every messaged if the message has a sender_id, otherwise is ends.
from chorus import me, receive, run, send, spawn
def echo():
match receive():
case (sender_id, msg):
send(sender_id, msg)
echo()
case _:
print("Echo: any other message means end.")
def main():
echo_id = spawn(echo)
send(echo_id, (me(), "hello"))
msg = receive()
print(f"received: {msg}")
send(echo_id, "end")
if __name__ == "__main__":
run(main)
Here is that same echo example using the chorus.dispatch API:
from typing import Any
from chorus import run, spawn_server
class EchoHandler:
def echo(self, message: Any) -> Any:
return message
def main():
proxy = spawn_server(EchoHandler())
result = proxy.ask.echo("hello")
print(result) # 'hello'
proxy.kill()
if __name__ == "__main__":
run(main)
Installation
Chorus requires Python 3.12 or later. The package name on Pypi is chorus-actors. To add it to a project using uv:
uv add chorus-actors
Or install it with pip:
python -m pip install chorus-actors
Documentation
The documentation can be found here.
Examples:
The examples are grouped by layer:
- runtime: actors, raw messages, main-thread execution, and drawing.
- messaging: message subclasses and request/reply exchanges.
- dispatch: counters, proxies, and GUI event-loop integration.
To run an example from the repository root:
uv run examples/dispatch/proxy_counter.py
License
This project is licensed under the MIT licence.
Metadata
Release files for chorus-actors 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chorus_actors-0.1.3.tar.gz | 9.8 kB | Without provenance | Details for chorus_actors-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chorus_actors-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for chorus_actors-0.1.3-py3-none-any.whl |
Total release size: 23.5 kB
Release files / chorus_actors-0.1.3.tar.gz
| Download URL | chorus_actors-0.1.3.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4074ba8fc6ff32697ec08fb0c6d80f9995a695ff867a18a6cc9e98b9bebe9122
|
|
BLAKE2b-256 checksum How to use checksums |
65b9d530abca7beb9098ae34c0f0ff7bd529e57d50ca43ede8290e9fe720c83f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / chorus_actors-0.1.3-py3-none-any.whl
| Download URL | chorus_actors-0.1.3-py3-none-any.whl |
|---|---|
| Size | 13.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
30a5efedbfa14032fe0e2e4c171dd950f17e0d6f72f0356b93bc9292ac8eaca9
|
|
BLAKE2b-256 checksum How to use checksums |
d8af318f4f1f3cbf09ddaf9e94f6e61f70e68f9943d96730fabfd3918bd1bd3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for chorus-actors 0.1.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.