利用 Capabilities API,您的应用可以检测特定 API 功能的服务中断情况和计划内停机时间。您可以使用此 API 来检测某项功能何时不可用并绕开这个时间,从而缩短应用停机时间。 。
例如,如果您使用 Images API 调整图片的大小,可以使用 Capabilities API 检测 Images API 何时不可用并跳过调整大小的步骤:
fromgoogle.appengine.apiimportcapabilitiesdefStoreUploadedProfileImage(self):uploaded_image=self.request.get('img')# If the images API is unavailable, we'll just skip the resize.ifcapabilities.CapabilitySet('images').is_enabled():uploaded_image=images.resize(uploaded_image,64,64)store(uploaded_image)
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-01。"],[[["The Capabilities API allows applications to detect outages and scheduled downtime for specific API capabilities, helping to reduce application downtime by bypassing unavailable features."],["This API supports first-generation runtimes and can be utilized when upgrading to corresponding second-generation runtimes, with specific migration guidance for the App Engine Python 3 runtime."],["While `is_enabled` generally returns `true`, the \"Datastore writes\" capability returns `false` if Datastore is in read-only mode."],["The API can be used by explicitly naming capabilities or by inferring them from the `CapabilitySet` class methods."],["The API currently supports capabilities like blobstore, Datastore reads and writes, Images, Mail, Memcache, Task Queue, and URL Fetch services."]]],[]]