Skip to main content

SyncFuture

This is a synchronous future, where the values are available immediately on construction. This is used to maintain a synonymous API with both Async and Sync tasks

Methods


Ready()

@classmethod
def Ready() - > bool

Checks if the future's value or error is available. This method always returns true for a SyncFuture as values are available immediately upon construction.

Returns

TypeDescription
boolTrue, indicating that the future is always ready.

Get()

@classmethod
def Get(
context: context.Context
) - > (interface{}, error)

Retrieves the value or error stored in the SyncFuture. Callers use this to access the result of the synchronous operation.

Parameters

NameTypeDescription
contextcontext.ContextThe context for the operation, which can be used for cancellation or to carry request-scoped values. For SyncFuture, this parameter typically has no effect as the result is already available.

Returns

TypeDescription
(interface{}, error)The actual value stored in the future, or an error if one occurred during the synchronous operation.