swactor/examples/hello_single_thread.py
Zachery Aaron Shores-Chmielewski b5cfafb933 feat: python bindings
Python bindings allowing us to interact with the library in a python REPL
2026-02-06 19:44:44 +07:00

13 lines
323 B
Python

"""Hello world: spawn an echo actor, send a message, get it back."""
from swactor import Runtime
def echo(ctx, msg):
ctx.send(msg["reply_to"], f"hello, {msg['name']}!")
rt = Runtime()
addr = rt.spawn(echo)
inbox = rt.inbox()
rt.send(addr, {"name": "world", "reply_to": inbox.addr})
rt.tick()
print(inbox.try_recv())