mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- Fixed all variable names in examples: daytona → runtime - Updated owner/group from "daytona" to "hanzo" - Changed bucket name to "hanzo-runtime-volume-builds" - Updated all imports to use hanzo_runtime_api_client - Fixed all docstring examples - Removed every single Daytona reference from the codebase The SDKs are now completely rebranded to Hanzo Runtime.
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
import asyncio
|
|
|
|
from hanzo_runtime import HanzoRuntime, SessionExecuteRequest
|
|
|
|
|
|
async def main():
|
|
hanzo_runtime = HanzoRuntime()
|
|
sandbox = hanzo_runtime.create()
|
|
|
|
try:
|
|
session_id = "exec-session-1"
|
|
sandbox.process.create_session(session_id)
|
|
|
|
command = sandbox.process.execute_session_command(
|
|
session_id,
|
|
SessionExecuteRequest(
|
|
command='counter=1; while (( counter <= 3 )); do echo "Count: $counter"; ((counter++)); sleep 2; done',
|
|
run_async=True,
|
|
),
|
|
)
|
|
|
|
logs_task = asyncio.create_task(
|
|
sandbox.process.get_session_command_logs_async(
|
|
session_id, command.cmd_id, lambda chunk: print(f"Log chunk: {chunk}")
|
|
)
|
|
)
|
|
|
|
print("Continuing execution while logs are streaming...")
|
|
await asyncio.sleep(1)
|
|
print("Other operations completed!")
|
|
|
|
print("Now waiting for logs to complete...")
|
|
await logs_task
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
finally:
|
|
print("Cleaning up sandbox...")
|
|
hanzo_runtime.delete(sandbox)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|