celery.result

    class celery.result.ResultBase

    Base class for all results

    • parent = None

      Parent result (if part of a chain)

    class celery.result.AsyncResult(id, backend=None, task_name=None, app=None, parent=None)[源代码]

    Query task state.

    • exception TimeoutError

      Error raised for timeouts.

    • AsyncResult.app = None

    • AsyncResult.as_tuple()

    • AsyncResult.backend = None

      The task result backend to use.

    • AsyncResult.build_graph(intermediate=False, formatter=None)

    • AsyncResult.children None[源代码]

    • AsyncResult.collect(intermediate=False, \*kwargs*)

      Iterator, like get() will wait for the task to complete, but will also follow and ResultSet returned by the task, yielding for each result in the tree.

      An example would be having the following tasks:

      Calling would return:

    • AsyncResult.failed()[源代码]

      Returns True if the task failed.

    • AsyncResult.forget()

      Forget about (and possibly remove the result of) this task.

    • AsyncResult.get(timeout=None, propagate=True, interval=0.5)[源代码]

      Wait until task is ready, and return its result.

      警告

      Waiting for tasks within a task may lead to deadlocks. Please read .

      参数:
      • timeout – How long to wait, in seconds, before the operation times out.
      • propagate – Re-raise exception if the task failed.
      • interval – Time to wait (in seconds) before retrying to retrieve the result. Note that this does not have any effect when using the amqp result store backend, as it does not use polling.
      引发 celery.exceptions.TimeoutError:
       

      if timeout is not None and the result does not arrive within timeout seconds.

      If the remote call raised an exception then that exception will be re-raised.

    • AsyncResult.get_leaf()

    • AsyncResult.graph None[源代码]

    • AsyncResult.id = None

      The task’s UUID.

    • AsyncResult.info None

      When the task has been executed, this contains the return value. If the task raised an exception, this will be the exception instance.

    • AsyncResult.iterdeps(intermediate=False)

    • AsyncResult.ready()[源代码]

      Returns True if the task has been executed.

      If the task is still running, pending, or is waiting for retry then False is returned.

    • AsyncResult.result None

      When the task has been executed, this contains the return value. If the task raised an exception, this will be the exception instance.

    • AsyncResult.revoke(connection=None, terminate=False, signal=None, wait=False, timeout=None)[源代码]

      Send revoke signal to all workers.

      Any worker receiving the task, or having reserved the task, must ignore it.

      参数:
      • terminate – Also terminate the process currently working on the task (if any).
      • signal – Name of signal to send to process if terminate. Default is TERM.
      • wait – Wait for replies from workers. Will wait for 1 second by default or you can specify a custom timeout.
    • AsyncResult.serializable()

    • AsyncResult.state None[源代码]

      The tasks current state.

      Possible values includes:

    • AsyncResult.status None

      Possible values includes:

      PENDING

      The task is waiting for execution.

      STARTED

      RETRY

      The task is to be retried, possibly because of failure.

      FAILURE

      The task raised an exception, or has exceeded the retry limit. The attribute then contains the exception raised by the task.

      SUCCESS

      The task executed successfully. The result attribute then contains the tasks return value.

    • AsyncResult.successful()

      Returns True if the task executed successfully.

    • AsyncResult.supports_native_join None[源代码]

    • AsyncResult.task_id None

      compat alias to

    • AsyncResult.traceback None[源代码]

      Get the traceback of a failed task.

    • AsyncResult.wait(timeout=None, propagate=True, interval=0.5)

      Wait until task is ready, and return its result.

      警告

      Waiting for tasks within a task may lead to deadlocks. Please read .

      参数:
      • timeout – How long to wait, in seconds, before the operation times out.
      • propagate – Re-raise exception if the task failed.
      • interval – Time to wait (in seconds) before retrying to retrieve the result. Note that this does not have any effect when using the amqp result store backend, as it does not use polling.
      引发 celery.exceptions.TimeoutError:
       

      if timeout is not None and the result does not arrive within timeout seconds.

      If the remote call raised an exception then that exception will be re-raised.

    class celery.result.ResultSet(results, app=None, \*kwargs*)

    Working with more than one result.

    参数:results – List of result instances.
    • add(result)[源代码]

      Add as a new member of the set.

      Does nothing if the result is already a member.

    • app = None

    • clear()[源代码]

      Remove all results from this set.

    • completed_count()

      Task completion count.

    • discard(result)[源代码]

      Remove result from the set if it is a member.

      If it is not a member, do nothing.

    • failed()

      Did any of the tasks fail?

      返回:True if one of the tasks failed. (i.e., raised an exception)
    • forget()[源代码]

      Forget about (and possible remove the result of) all the tasks.

    • get(timeout=None, propagate=True, interval=0.5, callback=None)

      See join()

      This is here for API compatibility with , in addition it uses join_native() if available for the current result backend.

    • iter_native(timeout=None, interval=0.5)

      Backend optimized version of iterate().

      2.2 新版功能.

      Note that this does not support collecting the results for different task types using different backends.

      This is currently only supported by the amqp, Redis and cache result backends.

    • iterate(timeout=None, propagate=True, interval=0.5)

      Iterate over the return values of the tasks as they finish one by one.

      Raises:The exception if any of the tasks raised an exception.
    • join(timeout=None, propagate=True, interval=0.5, callback=None)[源代码]

      Gathers the results of all tasks as a list in order.

      注解

      This can be an expensive operation for result store backends that must resort to polling (e.g. database).

      You should consider using if your backend supports it.

      警告

      Waiting for tasks within a task may lead to deadlocks. Please see Avoid launching synchronous subtasks.

      参数:
      • timeout – The number of seconds to wait for results before the operation times out.
      • propagate – If any of the tasks raises an exception, the exception will be re-raised.
      • interval – Time to wait (in seconds) before retrying to retrieve a result from the set. Note that this does not have any effect when using the amqp result store backend, as it does not use polling.
      • callback – Optional callback to be called for every result received. Must have signature (task_id, value) No results will be returned by this function if a callback is specified. The order of results is also arbitrary when a callback is used.
      引发 :
       
    • join_native(timeout=None, propagate=True, interval=0.5, callback=None)[源代码]

      Backend optimized version of .

      2.2 新版功能.

      Note that this does not support collecting the results for different task types using different backends.

      This is currently only supported by the amqp, Redis and cache result backends.

    • ready()[源代码]

      Did all of the tasks complete? (either by success of failure).

      返回:True if all of the tasks has been executed.
    • remove(result)

      Remove result from the set; it must be a member.

    • revoke(connection=None, terminate=False, signal=None, wait=False, timeout=None)[源代码]

      Send revoke signal to all workers for all tasks in the set.

      参数:
      • terminate – Also terminate the process currently working on the task (if any).
      • signal – Name of signal to send to process if terminate. Default is TERM.
      • wait – Wait for replies from worker. Will wait for 1 second by default or you can specify a custom timeout.
      • timeout – Time in seconds to wait for replies if wait enabled.
    • subtasks None

      Deprecated alias to results.

    • successful()

      Was all of the tasks successful?

      返回:True if all of the tasks finished successfully (i.e. did not raise an exception).
    • supports_native_join None[源代码]

    • update(results)

      Update set with the union of itself and an iterable with results.

    • waiting()[源代码]

      Are any of the tasks incomplete?

      返回:True if one of the tasks are still waiting for execution.

    class celery.result.GroupResult(id=None, results=None, \*kwargs*)

    Like ResultSet, but with an associated id.

    This type is returned by , and the deprecated TaskSet, meth:~celery.task.TaskSet.apply_async method.

    It enables inspection of the tasks state and return values as a single entity.

    参数:
    • id – The id of the group.
    • results – List of result instances.
    • as_tuple()

    • children None[源代码]

    • delete(backend=None)

      Remove this result if it was previously saved.

    • id = None

      The UUID of the group.

    • classmethod restore(id, backend=None)[源代码]

      Restore previously saved group result.

    • results = None

      List/iterator of results in the group

    • save(backend=None)

      Save group-result for later retrieval using restore().

      Example:

    • serializable()

    class celery.result.EagerResult(id, ret_value, state, traceback=None)[源代码]

    Result that we know has already been executed.

    • forget()

    • get(timeout=None, propagate=True, \*kwargs*)[源代码]

    • ready()

    • result None[源代码]

      The tasks return value

    • revoke(\args, **kwargs*)

    • state None[源代码]

      The tasks state.

    • status None

      The tasks state.

    • supports_native_join None

    • task_name = None

    • wait(timeout=None, propagate=True, \*kwargs*)

    celery.result.result_from_tuple(r, app=None)