Asynchronous Client API

The AsyncUESynthClient provides a high-performance, non-blocking API designed for real-time simulations, batch processing, and scenarios requiring thousands of operations per second.

Overview

The asynchronous client offers:

  • High throughput - 100-1000+ requests/second vs 10-50 for sync

  • Low latency - Minimal waiting between operations

  • Concurrent operations - Multiple requests in parallel

  • Streaming support - Bidirectional data streaming

  • Non-blocking - Doesn't freeze while waiting for responses

Performance Comparison

Feature
Sync Client
Async Client

Throughput

~10-50 req/sec

~100-1000+ req/sec

Latency

High accumulation

Minimal

Concurrent ops

Sequential only

Full parallelism

Use case

Simple scripts

High-performance sims

Getting Started

import asyncio
from uesynth import AsyncUESynthClient

async def main():
    # Connect to UESynth
    client = AsyncUESynthClient()
    await client.connect()
    
    try:
        # Your async code here...
        pass
    finally:
        # Always disconnect
        await client.disconnect()

# Run the async function
asyncio.run(main())

Client Configuration

Basic Connection

Advanced Options

Core Methods

Connection Management

connect()

Establish connection and initialize streaming.

disconnect()

Close connection and clean up resources.

is_connected()

Check connection status.

ping()

Test server responsiveness.

Request Modes

The async client supports two operation modes:

1. Streaming Mode (Non-blocking)

Operations return request IDs immediately and complete asynchronously.

2. Direct Mode (Blocking)

Operations wait for completion and return results directly.

Camera Control (Streaming)

Position and Rotation

camera.set_location(x, y, z)

Set camera position (non-blocking).

camera.set_rotation(pitch, yaw, roll)

Set camera rotation (non-blocking).

Camera Settings

camera.set_fov(fov)

Set field of view (non-blocking).

Camera Control (Direct)

Position and Rotation

camera.get_location_direct()

Get camera position (blocking, returns result).

camera.get_rotation_direct()

Get camera rotation (blocking, returns result).

camera.set_location_direct(x, y, z)

Set camera position and wait for completion.

Data Capture (Streaming)

Image Capture

capture.rgb(width=None, height=None)

Capture RGB image (non-blocking).

capture.depth(width=None, height=None)

Capture depth map (non-blocking).

capture.segmentation(width=None, height=None)

Capture segmentation (non-blocking).

Data Capture (Direct)

Image Capture

capture.rgb_direct(width=None, height=None)

Capture RGB image and return result immediately.

capture.depth_direct(width=None, height=None)

Capture depth map directly.

capture.all_modalities_direct(width=None, height=None)

Capture all data types directly.

Frame Management

Getting Captured Data

get_latest_frame()

Get the most recently captured frame.

get_frame_by_id(request_id)

Get a specific frame by its request ID.

wait_for_frame(request_id, timeout=5.0)

Wait for a specific frame to be ready.

Object Manipulation

Transform Control (Streaming)

objects.set_location(name, x, y, z)

Move object (non-blocking).

objects.set_rotation(name, pitch, yaw, roll)

Rotate object (non-blocking).

Transform Control (Direct)

objects.set_transform_direct(name, x, y, z, pitch=0, yaw=0, roll=0)

Set complete transform and wait for completion.

objects.get_transform_direct(name)

Get object transform directly.

High-Performance Patterns

Concurrent Operations

Real-time Simulation Loop

Batch Processing

Error Handling

Context Manager

Performance Tips

1. Use Streaming for High Throughput

2. Minimize Await Points

3. Configure Buffer Sizes

Complete Example

Next Steps

Last updated