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.
Class RetryParams
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
RetryParams
disediakan oleh library klien App Engine untuk Cloud Storage yang ada di src/cloudstorage
. Class ini memungkinkan Anda mengubah setelan default yang digunakan untuk
menangani waktu tunggu dan percobaan ulang.
Pengantar
Library klien App Engine untuk Cloud Storage menggunakan setelan default untuk menangani waktu tunggu dan percobaan ulang selama upaya untuk menghubungi server Google Cloud Storage.
Class ini memungkinkan Anda mengubah setelan tersebut, baik pada seluruh aplikasi maupun untuk pemanggilan fungsi library tertentu (copy2
, delete
, listbucket
, open
, stat
). Anda hanya perlu mengubah
setelan tertentu yang Anda minati, karena semua setelan lainnya akan dipertahankan
kecuali jika ditimpa secara eksplisit. Setiap instance RetryParams
bersifat unik per thread
dan per permintaan.
Untuk mengubah setelan default di seluruh aplikasi, buat objek RetryParams
, tentukan setelan apa pun yang ingin diubah, dan berikan objek ini ke
fungsi cloudstorage.set_default_retry_params()
seperti berikut:
my_default_retry_params = cloudstorage.RetryParams(initial_delay=0.2,
max_delay=5.0,
backoff_factor=2,
max_retry_period=15)
cloudstorage.set_default_retry_params(my_default_retry_params)
Untuk mengubah setelan default pemanggilan fungsi tertentu saja, buat objek RetryParams
dan berikan langsung ke fungsi di parameter retry_params
-nya, seperti berikut:
write_retry_params = cloudstorage.RetryParams(backoff_factor=1.1)
gcs_file = cloudstorage.open(filename,
'w',
content_type='text/plain',
options={'x-goog-meta-foo': 'foo',
'x-goog-meta-bar': 'bar'},
retry_params=write_retry_params)
Hal ini tidak memengaruhi setelan default yang digunakan oleh aplikasi atau pemanggilan fungsi lainnya.
Properti instance
Instance RetryParams
memiliki properti berikut:
- initial_delay
- Jumlah detik penundaan sebelum percobaan ulang. Default-nya adalah
0.1
. Penundaan membantu mendistribusikan beban di server Google Cloud Storage.
- backoff_factor
- Pengganda back-off eksponensial, yang digunakan untuk menentukan kecepatan pemrosesan
yang optimal. Default-nya adalah
2.0
. Untuk mengetahui deskripsi dan rekomendasi cara menetapkan nilai ini, lihat dokumentasi Google Cloud Storage tentang backoff.
- max_delay
- Jumlah detik maksimum untuk menunggu di antara percobaan ulang. Default-nya adalah
10.0
.
- min_retries
- Frekuensi minimum untuk mencoba ulang. Default-nya adalah
3
.
- max_retries
- Frekuensi maksimum untuk mencoba ulang. Tetapkan nilai ini ke 0 jika
Anda tidak menginginkan percobaan ulang. Default-nya adalah
6
.
- max_retry_period
- Jumlah detik maksimum yang dapat dihabiskan untuk semua percobaan ulang
permintaan tertentu. Default-nya adalah
30.0
. Percobaan ulang berhenti saat periode ini berlalu DAN
min_retries
telah dicoba.
- urlfetch_timeout
- Jumlah detik untuk menunggu UrlFetch menghubungi server Google Cloud Storage sebelum menampilkan error waktu tunggu habis. Secara default, atribut ini disetel ke
None
, yang berarti gunakan batas waktu UrlFetch default, yaitu lima detik. Anda dapat menetapkannya ke nilai apa pun dengan nilai maksimum 60
detik.
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-09-04 UTC.
[[["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\u003e\u003ccode\u003eRetryParams\u003c/code\u003e allows customization of timeout and retry settings for the App Engine client library's interactions with Cloud Storage.\u003c/p\u003e\n"],["\u003cp\u003eYou can adjust settings such as \u003ccode\u003einitial_delay\u003c/code\u003e, \u003ccode\u003ebackoff_factor\u003c/code\u003e, \u003ccode\u003emax_delay\u003c/code\u003e, \u003ccode\u003emin_retries\u003c/code\u003e, \u003ccode\u003emax_retries\u003c/code\u003e, \u003ccode\u003emax_retry_period\u003c/code\u003e, and \u003ccode\u003eurlfetch_timeout\u003c/code\u003e to control retry behavior.\u003c/p\u003e\n"],["\u003cp\u003eSettings can be changed application-wide using \u003ccode\u003ecloudstorage.set_default_retry_params()\u003c/code\u003e or for specific function calls by providing \u003ccode\u003eretry_params\u003c/code\u003e to the function directly.\u003c/p\u003e\n"],["\u003cp\u003eEach \u003ccode\u003eRetryParams\u003c/code\u003e instance is specific to a thread and request, allowing for granular control over retries without affecting other parts of the application.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eurlfetch_timeout\u003c/code\u003e setting lets users determine how many seconds to wait for UrlFetch to contact the Cloud Storage servers, defaulting to 5 seconds, but going as high as 60 seconds.\u003c/p\u003e\n"]]],[],null,["# The RetryParams Class\n\n`RetryParams` is provided by the App Engine client library for Cloud Storage contained\nin `src/cloudstorage`. This class lets you change default settings used to\nhandle timeouts and retries.\n\nIntroduction\n------------\n\nThe App Engine client library for Cloud Storage uses default settings for handling\ntimeouts and retries during attempts to contact Google Cloud Storage servers.\nThis class allows you to change those settings, either on an application-wide\nbasis, or for a specific invocation of a library\nfunction (`copy2`, `delete`, `listbucket`, `open`, `stat`). You need change only\nthe specific setting you are interested in, as all other settings are retained\nunless explicitly overwritten. Each `RetryParams` instance is unique per thread\nand per request.\n\nTo change a default setting application-wide, you create a `RetryParams`\nobject, specify whatever settings you wish to change, and supply this object to\nthe `cloudstorage.set_default_retry_params()` function as follows: \n\n my_default_retry_params = cloudstorage.RetryParams(initial_delay=0.2,\n max_delay=5.0,\n backoff_factor=2,\n max_retry_period=15)\n cloudstorage.set_default_retry_params(my_default_retry_params)\n\nTo change default settings for a specific function invocation only, create\na `RetryParams` object and supply it directly to the function in its\n`retry_params` parameter, as follows: \n\n write_retry_params = cloudstorage.RetryParams(backoff_factor=1.1)\n gcs_file = cloudstorage.open(filename,\n 'w',\n content_type='text/plain',\n options={'x-goog-meta-foo': 'foo',\n 'x-goog-meta-bar': 'bar'},\n retry_params=write_retry_params)\n\nThis has no effect on the default settings used by the app or by other\nfunction invocations.\n\nInstance properties\n-------------------\n\nA `RetryParams` instance has the following properties:\n\ninitial_delay\n: The number of seconds to delay before a retry. Default is `0.1`. Delay helps\n distribute load at the Google Cloud Storage server.\n\nbackoff_factor\n: The exponential back-off multiplier, used to determine optimal processing\n rate. Default is `2.0`. For a description and recommendations for setting this\n value, see the Google Cloud Storage documentation on [backoff](/storage/docs/exponential-backoff).\n\nmax_delay\n: The maximum number of seconds to wait between retries. Default is `10.0`.\n\nmin_retries\n: The minimum number of times to retry. Default is `3`.\n\nmax_retries\n: The maximum number of times to retry. Set this value to 0 if\n you don't want any retries. Default is `6`.\n\nmax_retry_period\n: The maximum number of seconds that can be spent on all retries of a\n given request. Default is `30.0`. Retry stops when this period passed AND\n `min_retries` has been attempted.\n\nurlfetch_timeout\n: The number of seconds to wait for UrlFetch to contact the\n Google Cloud Storage servers before returning a timeout error. By default,\n this is set to `None`, which means use the [default UrlFetch deadline](/appengine/docs/legacy/standard/python/issue-requests),\n which is five seconds. You can set this to any value up to a maximum of 60\n seconds."]]