AsyncFuture
No overview available.
Methods
set()
@classmethod
def set(
val: interface{},
err: error
)
Sets the result of the asynchronous operation, either a value or an error. This method marks the future as complete and makes its result available.
Parameters
| Name | Type | Description |
|---|---|---|
| val | interface{} | The value to be stored as the successful result of the future. |
| err | error | An error to be stored as the failed result of the future. If an error is provided, 'val' should typically be nil. |
get()
@classmethod
def get() - > (interface{}, error)
Retrieves the result of the asynchronous operation. This method blocks until the future is complete and a value or an error has been set.
Returns
| Type | Description |
|---|---|
(interface{}, error) | The value and any error associated with the completed asynchronous operation. |
Ready()
@classmethod
def Ready() - > bool
Checks if the asynchronous operation has completed. 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 result of the asynchronous operation, respecting the provided context for cancellation or timeouts. This method blocks until the future is complete or the context is cancelled/times out.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context that can be used to cancel the wait or set a timeout for retrieving the future's result. |
Returns
| Type | Description |
|---|---|
(interface{}, error) | The value and any error associated with the completed asynchronous operation, or a context error if the context is cancelled or times out before the future completes. |