Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.

NDB Future Class

Stay organized with collections Save and categorize content based on your preferences.

A Future represents the result of an asynchronous operation. When created, it probably doesn't have any result data. When the operation finishes, the Future gets the result. An application can call a Future object's get_result() method; if the result has arrived, the method returns it; otherwise, it waits for the result to arrive and then returns it.

Note: There is no 1:1 mapping between RPCs and Futures. Multiple futures might be tied to a result from a single RPC.

Instance Methods

Check to see if the operation succeeded. Waits if necessary. Raises an exception if there was a problem; returns None if there was no problem.
Returns True if the result (or exception) has arrived; otherwise, returns False. This function does not wait.
Waits if necessary; then returns the exception (or None if there was no exception). Returns the exception, doesn't raise it.
Waits if necessary; then returns the result or raises the exception.
Waits if necessary; then returns the exception's traceback object (or None if there was no traceback object). Python's traceback module has functions to print and work with traceback objects.
Waits until a result or exception arrives. Always returns None.

Class Methods

Wait until all Futures in the passed iterable are done.


Iterable of Future objects.

Returns None.

Wait until at least one of a iterable of Futures is done.


Iterable of Future objects.

Returns one Future that is done. (Returns None if the futures iterable is empty.)