Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

NDB Future Class

This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment. If you are updating to the App Engine Python 3 runtime, refer to themigration guide to learn about your migration options for legacy bundled services.

AFuture represents the result of anasynchronous operation. When created, it probably doesn't have any result data. When the operation finishes, theFuture gets the result. An application can call aFuture object'sget_result() method; if the result has arrived, the method returns it; otherwise, it waits for the result to arrive andthen 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_success()
Check to see if the operation succeeded. Waits if necessary. Raises an exception if there was a problem; returnsNone if there was no problem.
done()
ReturnsTrue if the result (or exception) has arrived; otherwise, returnsFalse. This function does not wait.
get_exception()
Waits if necessary; then returns the exception (orNone if there was no exception).Returns the exception, doesn't raise it.
get_result()
Waits if necessary; then returns the result or raises the exception.
get_traceback()
Waits if necessary; then returns the exception's traceback object (orNone if there was no traceback object). Python'straceback module has functions to print and work withtraceback objects.
wait()
Waits until a result or exception arrives. Always returnsNone.

Class Methods

wait_all(futures)
Wait until allFutures in the passed iterable are done.

Arguments

futures
Iterable ofFuture objects.

ReturnsNone.

wait_any(futures)
Wait until at least one of a iterable ofFutures is done.

Arguments

futures
Iterable ofFuture objects.

Returns oneFuture that is done. (ReturnsNone if thefutures iterable is empty.)

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.