利用 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-08-20。"],[[["\u003cp\u003eThe Capabilities API allows applications to detect outages and scheduled downtime for specific API capabilities, helping to reduce application downtime by bypassing unavailable features.\u003c/p\u003e\n"],["\u003cp\u003eThis 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.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003eis_enabled\u003c/code\u003e generally returns \u003ccode\u003etrue\u003c/code\u003e, the "Datastore writes" capability returns \u003ccode\u003efalse\u003c/code\u003e if Datastore is in read-only mode.\u003c/p\u003e\n"],["\u003cp\u003eThe API can be used by explicitly naming capabilities or by inferring them from the \u003ccode\u003eCapabilitySet\u003c/code\u003e class methods.\u003c/p\u003e\n"],["\u003cp\u003eThe API currently supports capabilities like blobstore, Datastore reads and writes, Images, Mail, Memcache, Task Queue, and URL Fetch services.\u003c/p\u003e\n"]]],[],null,[]]