aioerl
aioerl is a python library that mimics the philosophy of Erlang's processes with asyncio tasks.
Implements the following ideas:
- Each process has a mailbox: a queue to receive messages from other processes.
- Message passing: processes communicate entirely with messages (from the point of view of the developer)
- Supervisor/monitors: processes can monitor other processes (when a process dies or crashes, sends a message to its supervisor with the exit reason or the exception)
Why?
asyncio is awesome and built-in structures like asyncio.Queue are great for communicating between tasks but is hard to manage errors.
With aioerl, a process just waits for incoming messages from other processes and decides what to do for each event (see example).
Quickstart
Requirements: Python 3.7+
Installation:
pip install aioerl
Example
from aioerl import spawn_monitored, receive, reply, send, run
async def ping_pong():
while True:
m = await receive(timeout=10)
if m.is_ok:
if m.body == "ping":
await reply("pong")
else:
raise Exception("Invalid message body")
elif m.is_timeout:
return # terminate process
async def main():
p = await spawn_monitored(ping_pong())
await send(p, "ping")
print(await receive()) # Message(sender=<ErlProc:2>, event='ok', body='pong')
await send(p, "pang")
print(await receive()) # Message(sender=<ErlProc:2>, event='err', body=Exception("Invalid message body"))
await send(p, "ping")
print(await receive()) # Message(sender=<ErlProc:2>, event='exit', body='noproc')
if __name__ == "__main__":
run(main())
TODO:
Lot of things!
Metadata
Release files for aioerl 0.0.20190425
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 |
|---|---|---|---|---|
| aioerl-0.0.20190425.tar.gz | 3.9 kB | Without provenance | Details for aioerl-0.0.20190425.tar.gz |
Release files / aioerl-0.0.20190425.tar.gz
| Download URL | aioerl-0.0.20190425.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c14d4adca3e6738b2f5d95ee0beb1efe802082b0b1897a3cf420bc3d76a66b3c
|
|
BLAKE2b-256 checksum How to use checksums |
c8c95e3ef9a302f65b97587527d02c9e8554e5b52be18387569e0b7ddb1756f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for aioerl 0.0.20190425
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.