File tree Expand file tree Collapse file tree
nexus_standalone_operations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ uv run nexus_standalone_operations/starter.py
5353
5454```
5555Echo result: hello
56+ Echo result from existing operation handle: hello
5657
5758Started `MyNexusService.Hello`. OperationID: hello-...
5859`MyNexusService.Hello` result: Hello, World!
Original file line number Diff line number Diff line change 1414
1515from nexus_standalone_operations .service import (
1616 EchoInput ,
17+ EchoOutput ,
1718 HelloInput ,
1819 MyNexusService ,
1920)
@@ -33,14 +34,22 @@ async def main() -> None:
3334 )
3435
3536 # Start sync echo operation and await the result immediately.
37+ operation_id = f"echo-{ uuid .uuid4 ()} "
3638 echo_result = await nexus_client .execute_operation (
3739 MyNexusService .echo ,
3840 EchoInput (message = "hello" ),
39- id = f"echo- { uuid . uuid4 () } " ,
41+ id = operation_id ,
4042 schedule_to_close_timeout = timedelta (seconds = 10 ),
4143 )
4244 print (f"Echo result: { echo_result .message } " )
4345
46+ # Get a handle and the result of an existing operation
47+ existing_op_handle = client .get_nexus_operation_handle (
48+ operation_id , operation = MyNexusService .echo
49+ )
50+ existing_result = await existing_op_handle .result ()
51+ print (f"Echo result from existing operation handle: { existing_result .message } " )
52+
4453 # Start async (workflow-backed) hello operation and get a NexusOperationHandle.
4554 handle = await nexus_client .start_operation (
4655 MyNexusService .hello ,
You can’t perform that action at this time.
0 commit comments