Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Ein Future stellt das Ergebnis eines asynchronen Vorgangs dar.
Bei der Erstellung hat es wahrscheinlich keine Ergebnisdaten.
Wenn der Vorgang abgeschlossen ist, erhält das Future das Ergebnis.
Eine Anwendung kann die Methode get_result() eines Future-Objekts aufrufen. Wenn das Ergebnis eingegangen ist, wird es durch die Methode zurückgegeben. Andernfalls wird auf das Ergebnis gewartet und dann wird es zurückgegeben.
Hinweis: Es gibt keine 1:1-Zuordnung zwischen RPCs und Futures. Mehrere Futures können an ein Ergebnis eines einzelnen RPC gebunden sein.
Instanzmethoden
check_success()
Prüft, ob der Vorgang erfolgreich war. Wartet, wenn nötig.
Löst eine Ausnahme aus, wenn ein Problem aufgetreten ist. Gibt None zurück, wenn kein Problem aufgetreten ist.
done()
Gibt True zurück, wenn das Ergebnis (oder die Ausnahme) eingegangen ist. Andernfalls wird False zurückgegeben. Diese Funktion wartet nicht.
get_exception()
Wartet, falls erforderlich. Gibt dann die Ausnahme zurück (oder None, wenn es keine Ausnahme gab). Gibt die Ausnahme zurück, löst sie aber nicht aus.
get_result()
Wartet, falls erforderlich. Gibt dann das Ergebnis zurück oder löst die Ausnahme aus.
get_traceback()
Wartet, falls erforderlich. Gibt dann das Traceback-Objekt der Ausnahme zurück (oder None, wenn kein Traceback-Objekt vorhanden ist).
Das
traceback-Modul von Python hat Funktionen für die Anwendung von Traceback-Objekten und deren Ausgabe.
wait()
Wartet, bis ein Ergebnis oder eine Ausnahme eingeht.
Gibt immer None zurück.
Klassenmethoden
wait_all(futures)
Wartet, bis alle Futures in der übergebenen Iteration abgeschlossen sind.
Argumente
futures
Iteration von Future-Objekten.
Gibt None zurück.
wait_any(futures)
Wartet, bis mindestens eine Iteration von Futures abgeschlossen ist.
Argumente
futures
Iteration von Future-Objekten.
Gibt ein abgeschlossenes Future zurück.
(Gibt None zurück, wenn die Iteration futures leer ist.)
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eThis page outlines how to utilize legacy bundled services and APIs, which are exclusive to first-generation runtimes within the App Engine standard environment.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eFuture\u003c/code\u003e object represents the outcome of an asynchronous operation and stores the result once the operation is complete.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFuture\u003c/code\u003e object includes methods like \u003ccode\u003eget_result()\u003c/code\u003e to retrieve the result, \u003ccode\u003echeck_success()\u003c/code\u003e to confirm the operation's success, and \u003ccode\u003edone()\u003c/code\u003e to check if the operation has finished.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ewait_all\u003c/code\u003e and \u003ccode\u003ewait_any\u003c/code\u003e are class methods that allow you to wait for multiple \u003ccode\u003eFutures\u003c/code\u003e to complete, either waiting for all to finish or waiting until at least one is done.\u003c/p\u003e\n"]]],[],null,["# NDB Future Class\n\n| 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 the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\nA `Future` represents the result of an\n[asynchronous operation](/appengine/docs/legacy/standard/python/ndb/async).\nWhen created, it probably doesn't have any result data.\nWhen the operation finishes, the `Future` gets the result.\nAn application can call a `Future` object's\n`get_result()` method; if the result has arrived, the\nmethod returns it; otherwise, it waits for the result to arrive and\n*then* returns it.\n\n**Note:** There is no 1:1 mapping between RPCs and Futures. Multiple futures might be tied to a result from a single RPC.\n\nInstance Methods\n----------------\n\ncheck_success()\n: Check to see if the operation succeeded. Waits if necessary.\n Raises an exception if there was a problem; returns `None`\n if there was no problem.\n\ndone()\n: Returns `True` if the result (or exception) has arrived;\n otherwise, returns `False`. This function does not wait.\n\nget_exception()\n: Waits if necessary; then returns the exception (or `None` if\n there was no exception). *Returns* the exception, doesn't raise it.\n\nget_result()\n: Waits if necessary; then returns the result or raises the exception.\n\nget_traceback()\n: Waits if necessary; then returns the exception's traceback\n object (or `None` if there was no traceback object).\n Python's\n [traceback](http://docs.python.org/library/traceback.html) module has functions to print and work with\n traceback objects.\n\nwait()\n: Waits until a result or exception arrives.\n Always returns `None`.\n\nClass Methods\n-------------\n\nwait_all(futures)\n: Wait until all `Futures` in the passed iterable are done.\n\n **Arguments**\n\n futures\n : Iterable of `Future` objects.\n\n\n Returns `None`.\n\nwait_any(futures)\n: Wait until at least one of a iterable of `Futures` is done.\n\n **Arguments**\n\n futures\n : Iterable of `Future` objects.\n\n\n Returns one `Future` that is done.\n (Returns `None` if the `futures` iterable is empty.)"]]