EagerResult
Result that we know has already been executed.
Attributes
| Attribute | Type | Description |
|---|---|---|
| wait | method | Alias for the get method used to retrieve the task result or re-raise exceptions. |
| status | string | The tasks state. |
Constructor
Signature
def EagerResult(
id: string,
ret_value: any,
state: string,
traceback: string = None,
name: string = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| id | string | The unique identifier for the task. |
| ret_value | any | The value returned by the task execution. |
| state | string | The current state of the task. |
| traceback | string = None | The traceback information if the task failed. |
| name | string = None | The name of the task. |
Methods
then()
@classmethod
def then(
callback: callable,
on_error: callable = null,
weak: boolean = false
) - > promise
Registers a callback to be executed when the result is ready, which in this eager context occurs immediately.
Parameters
| Name | Type | Description |
|---|---|---|
| callback | callable | The function to invoke with the task result upon successful completion. |
| on_error | callable = null | The function to invoke if the task failed with an exception. |
| weak | boolean = false | If true, allows the callback to be garbage collected if no other references exist. |
Returns
| Type | Description |
|---|---|
promise | A promise object that resolves when the callback or error handler completes. |
ready()
@classmethod
def ready() - > boolean
Indicates whether the task has finished executing; always returns True for eager results.
Returns
| Type | Description |
|---|---|
boolean | Always True, as eager tasks are executed synchronously. |
get()
@classmethod
def get(
timeout: float = null,
propagate: boolean = true,
disable_sync_subtasks: boolean = true
) - > any
Retrieves the result of the task, optionally propagating exceptions if the task failed.
Parameters
| Name | Type | Description |
|---|---|---|
| timeout | float = null | The maximum time to wait for the result; ignored as the result is already available. |
| propagate | boolean = true | Whether to raise the task's exception if the task failed. |
| disable_sync_subtasks | boolean = true | If enabled, asserts that the call will not block the current thread. |
Returns
| Type | Description |
|---|---|
any | The return value of the task if successful, or the exception/result if propagation is disabled. |
forget()
@classmethod
def forget()
Removes the result from the backend; this is a no-op for eager results as they are not stored in a remote backend.
revoke()
@classmethod
def revoke(
*args: any,
**kwargs: any
)
Sets the task state to REVOKED; note that for eager results, the task has already finished execution.
Parameters
| Name | Type | Description |
|---|---|---|
| *args | any | Positional arguments passed to the revoke command. |
| **kwargs | any | Keyword arguments passed to the revoke command. |
result()
@classmethod
def result() - > any
The tasks return value.
Returns
| Type | Description |
|---|---|
any | The value returned by the executed task. |
state()
@classmethod
def state() - > string
The tasks state.
Returns
| Type | Description |
|---|---|
string | The current status of the task (e.g., SUCCESS, FAILURE). |
traceback()
@classmethod
def traceback() - > string
The traceback if the task failed.
Returns
| Type | Description |
|---|---|
string | The stack trace string if an exception occurred, otherwise None. |
supports_native_join()
@classmethod
def supports_native_join() - > boolean
Indicates if the result backend supports native join operations; always False for eager results.
Returns
| Type | Description |
|---|---|
boolean | Always False. |