Skip to main content

EagerResult

Result that we know has already been executed.

Attributes

AttributeTypeDescription
waitmethodAlias for the get method used to retrieve the task result or re-raise exceptions.
statusstringThe tasks state.

Constructor

Signature

def EagerResult(
id: string,
ret_value: any,
state: string,
traceback: string = None,
name: string = None
) - > null

Parameters

NameTypeDescription
idstringThe unique identifier for the task.
ret_valueanyThe value returned by the task execution.
statestringThe current state of the task.
tracebackstring = NoneThe traceback information if the task failed.
namestring = NoneThe 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

NameTypeDescription
callbackcallableThe function to invoke with the task result upon successful completion.
on_errorcallable = nullThe function to invoke if the task failed with an exception.
weakboolean = falseIf true, allows the callback to be garbage collected if no other references exist.

Returns

TypeDescription
promiseA 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

TypeDescription
booleanAlways 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

NameTypeDescription
timeoutfloat = nullThe maximum time to wait for the result; ignored as the result is already available.
propagateboolean = trueWhether to raise the task's exception if the task failed.
disable_sync_subtasksboolean = trueIf enabled, asserts that the call will not block the current thread.

Returns

TypeDescription
anyThe 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

NameTypeDescription
*argsanyPositional arguments passed to the revoke command.
**kwargsanyKeyword arguments passed to the revoke command.

result()

@classmethod
def result() - > any

The tasks return value.

Returns

TypeDescription
anyThe value returned by the executed task.

state()

@classmethod
def state() - > string

The tasks state.

Returns

TypeDescription
stringThe current status of the task (e.g., SUCCESS, FAILURE).

traceback()

@classmethod
def traceback() - > string

The traceback if the task failed.

Returns

TypeDescription
stringThe 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

TypeDescription
booleanAlways False.