AsyncFuture
No overview available.
Methods
set()
@classmethod
def set(
val: interface{},
err: error
)
Sets the result of the future with a value or an error. This method marks the future as ready and unblocks any callers waiting on get() or Get().
Parameters
| Name | Type | Description |
|---|---|---|
| val | interface{} | The value to be stored in the future upon completion. |
| err | error | An error to be stored in the future if the operation failed. |
get()
@classmethod
def get() - > (interface{}, error)
Retrieves the value and error from the future. This method blocks until the future is ready (i.e., set() has been called).
Returns
| Type | Description |
|---|---|
(interface{}, error) | The value and error stored in the future. The value will be nil if an error occurred, and the error will be nil if the operation was successful. |
Ready()
@classmethod
def Ready() - > bool
Checks if the future has completed and its result is available. Callers can use this to poll the future's status without blocking.
Returns
| Type | Description |
|---|---|
bool | True if the future has completed (either successfully or with an error), false otherwise. |
Get()
@classmethod
def Get(
ctx: context.Context
) - > (interface{}, error)
Retrieves the value and error from the future, respecting a provided context for cancellation or timeouts. This method blocks until the future is ready or the context is cancelled/times out.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context to use for cancellation and timeout. If the context is cancelled, this method will return early with the context's error. |
Returns
| Type | Description |
|---|---|
(interface{}, error) | The value and error stored in the future. If the context is cancelled or times out before the future is ready, the context's error will be returned. |