Python 2.7 ha raggiunto la fine del supporto
e verrà ritirato
il 31 gennaio 2026. Dopo il ritiro, non potrai eseguire il deployment di applicazioni Python 2.7, anche se la tua organizzazione ha utilizzato in precedenza un criterio dell'organizzazione per riattivare i deployment di runtime legacy. Le tue applicazioni Python 2.7 esistenti continueranno a essere eseguite e a ricevere traffico dopo la
data di ritiro. Ti consigliamo di eseguire la migrazione all'ultima versione supportata di Python.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Un Future rappresenta il risultato di un'operazione asincrona.
Al momento della creazione, probabilmente non contiene dati sui risultati.
Al termine dell'operazione, Future riceve il risultato.
Un'applicazione può chiamare il metodo get_result() di un oggetto Future. Se il risultato è arrivato, il metodo lo restituisce. In caso contrario, attende che il risultato venga visualizzato e poi lo restituisce.
Nota:non esiste una mappatura 1:1 tra RPC e Futures. Più future potrebbero essere collegate al risultato di una singola RPC.
Metodi istanza
check_success()
Controlla se l'operazione è riuscita. Attende, se necessario.
Genera un'eccezione se si è verificato un problema; restituisce None
se non si è verificato alcun problema.
done()
Restituisce True se il risultato (o l'eccezione) è arrivato, altrimenti restituisce False. Questa funzione non attende.
get_exception()
Attende se necessario, quindi restituisce l'eccezione (o None se
non è stata generata alcuna eccezione). Restituisce l'eccezione, non la solleva.
get_result()
Attende, se necessario, quindi restituisce il risultato o solleva l'eccezione.
get_traceback()
Attende, se necessario, quindi restituisce l'oggetto traceback
dell'eccezione (o None se non è presente alcun oggetto traceback).
Il modulo
traceback di Python contiene funzioni per stampare e utilizzare gli oggetti traceback.
wait()
Attende l'arrivo di un risultato o di un'eccezione.
Restituisce sempre None.
Metodi di classe
wait_all(futures)
Attendi il completamento di tutti i Futures nell'iterable passato.
Argomenti
futures
Iterable di oggetti Future.
Restituisce None.
wait_any(futures)
Attendi il completamento di almeno uno di un iterable di Futures.
Argomenti
futures
Iterable di oggetti Future.
Restituisce un Future completato.
Restituisce None se l'iterable futures è vuoto.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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.)"]]