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
| Type | Description |
|---|---|
bool | True, 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
| Name | Type | Description |
|---|---|---|
| context | context.Context | The 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
| Type | Description |
|---|---|
(interface{}, error) | The actual value stored in the future, or an error if one occurred during the synchronous operation. |