Future
This interface provides a Future API for asynchronous completion of tasks. It allows checking if a task is ready and retrieving its computed value or error, potentially blocking until completion.
Methods
Ready()
@classmethod
def Ready() - > bool
Returns true if the Future is ready and either a value or error is available. Once Ready returns True, Get should return immediately.
Returns
| Type | Description |
|---|---|
bool | True if the future has completed and its result is available, otherwise False. |
Get()
@classmethod
def Get(
ctx: context.Context
) - > (interface{}, error)
Get is a potentially blocking call, that returns the asynchronously computed value or an error. If Get is called before Ready() returns True, then it will block till the future has been completed.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, which can be used to cancel the blocking call. |
Returns
| Type | Description |
|---|---|
(interface{}, error) | The asynchronously computed value or an error if the computation failed. |