NDB Future Class Stay organized with collections Save and categorize content based on your preferences.
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; returns
Noneif there was no problem. - done()
- Returns
Trueif the result (or exception) has arrived; otherwise, returnsFalse. This function does not wait. - get_exception()
- Waits if necessary; then returns the exception (or
Noneif 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 (or
Noneif there was no traceback object). Python'stracebackmodule has functions to print and work withtraceback objects. - wait()
- Waits until a result or exception arrives. Always returns
None.
Class Methods
- wait_all(futures)
- Wait until all
Futuresin the passed iterable are done.Arguments
- futures
- Iterable of
Futureobjects.
Returns
None. - wait_any(futures)
- Wait until at least one of a iterable of
Futuresis done.Arguments
- futures
- Iterable of
Futureobjects.
Returns one
Futurethat is done. (ReturnsNoneif thefuturesiterable 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.