APIFuture
Generic interface for asynchronous operations
Classes
APIFuture<T>
Abstract generic class representing an asynchronous operation that will produce a value of type T.
AwaitableConcurrentFuture<T>
Concrete implementation wrapping Python’s concurrent.futures.Future with async/await support.
Methods
result_async
async def result_async(timeout: Optional[float] = None) -> TGet the result asynchronously (non-blocking).
Parameters:
timeout- Optional timeout in seconds
Raises: TimeoutError if operation doesn’t complete within timeout.
result
def result(timeout: Optional[float] = None) -> TGet the result synchronously (blocking).
Parameters:
timeout- Optional timeout in seconds
Raises: TimeoutError if operation doesn’t complete within timeout.
future
def future() -> concurrent.futures.Future\[T\]Access the underlying concurrent.futures.Future object.
Usage
Asynchronous
api_future = await client.some_operation_async(...)
result = await api_futureSynchronous
api_future = client.some_operation(...)
result = api_future.result()With Timeout
try:
result = api_future.result(timeout=30.0) # 30 seconds
except TimeoutError:
print("Operation timed out")