Python 2.7 telah mencapai akhir dukungan
dan akan dihentikan penggunaannya
pada 31 Januari 2026. Setelah penghentian penggunaan, Anda tidak akan dapat men-deploy aplikasi Python 2.7, meskipun organisasi Anda sebelumnya menggunakan kebijakan organisasi untuk mengaktifkan kembali deployment runtime lama. Aplikasi Python 2.7 yang ada akan terus berjalan dan menerima traffic setelah
tanggal penghentiannya. Sebaiknya Anda bermigrasi ke versi Python terbaru yang didukung.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Future menampilkan hasil dari
operasi asinkron.
Saat dibuat, pengujian mungkin tidak memiliki data hasil apa pun.
Setelah operasi selesai, Future akan mendapatkan hasilnya.
Aplikasi dapat memanggil metode get_result()
objek Future; jika hasilnya telah sampai,
metode akan menampilkannya; jika tidak, komputer akan menunggu hasilnya tiba dan
kemudian menampilkannya.
Catatan: Tidak ada pemetaan 1:1 antara RPC dan Future. Beberapa future mungkin terkait dengan hasil dari satu RPC.
Metode Instance
check_success()
Periksa apakah operasi berhasil. Tunggu jika perlu.
Mengajukan pengecualian jika ada masalah; menampilkan None
jika tidak ada masalah.
done()
Menampilkan True jika hasil (atau pengecualian) telah tiba;
jika tidak, menampilkan False. Fungsi ini tidak menunggu.
get_exception()
Menunggu jika diperlukan; kemudian menampilkan pengecualian (atau None jika
tidak ada pengecualian). Menampilkan pengecualian, tidak mengajukannya.
get_result()
Menunggu jika diperlukan; lalu menampilkan hasilnya atau mengajukan pengecualian.
get_traceback()
Menunggu jika diperlukan; kemudian menampilkan objek traceback pengecualian (atau None jika tidak ada objek traceback).
Modul
traceback Python memiliki fungsi untuk mencetak dan bekerja
dengan objek traceback.
wait()
Menunggu hingga hasil atau pengecualian tiba.
Selalu menampilkan None.
Metode Class
wait_all(future)
Menunggu hingga semua Futures dalam iterable yang diteruskan selesai.
Argumen
future
Iterable dari objek Future.
Menampilkan None.
wait_any(future)
Menunggu hingga setidaknya salah satu iterable Futures selesai.
Argumen
future
Iterable dari objek Future.
Menampilkan satu Future yang selesai.
(Menampilkan None jika iterable futures kosong.)
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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.)"]]