Created
August 27, 2025 11:39
-
-
Save dtornow/d0732873717bfcb6421604ca1f0fce90 to your computer and use it in GitHub Desktop.
Getting Started
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # run with uv run --with 'resonate-sdk>=0.6.2' foo.py | |
| from resonate import Resonate, Context | |
| resonate = Resonate.local() | |
| @resonate.register | |
| def foo(ctx, greeting): | |
| print("running foo") | |
| # async | |
| promise = yield ctx.begin_run(bar, greeting) | |
| print("P", promise) | |
| # await | |
| greeting = yield promise | |
| print("R", greeting) | |
| # sync | |
| greeting = yield ctx.run(baz, greeting) | |
| print("R", greeting) | |
| return greeting | |
| def bar(_, greeting): | |
| print(f"bar called with: {greeting}") | |
| return f"bar: {greeting}" | |
| def baz(_, greeting): | |
| print(f"baz called with: {greeting}") | |
| return f"baz: {greeting}" | |
| def main(): | |
| resonate.start() | |
| handles = [resonate.begin_run(f"test-foo-lfi-{i}", "foo", f"hello-{i}") for i in range(5)] | |
| results = [handle.result() for handle in handles] | |
| print(results) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment