python - AdWords RateExceededError
问题描述
我正在构建一个帮助程序库来调用 AdWords (Google Ads) Keyword Planner API,并且在出现 RateExceededError 错误时遇到了麻烦。
我收到的具体错误消息如下。
GoogleAdsServerFault: RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30, errorDetails="Quota check failed: QuotaInfo{quotaGroupId=v2-kwi-webapi-global, userId=global}"> Original AdsAPI trace for debugging [
com.google.ads.api.services.common.error.ApiException: RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30, errorDetails="Quota check failed: QuotaInfo{quotaGroupId=v2-kwi-webapi-global, userId=global}">
Underlying ApiErrors are:
RateExceededError <rateName=RATE_LIMIT, rateKey=null, rateScope=ACCOUNT, retryAfterSeconds=30>
我目前正在使用以下设置来调用 API 并捕获错误,但偶尔仍会引发异常。有没有更好的方法来捕获这些错误并将异常记录为警告?
class AdwordsAPIException(Exception):
pass
def call_adwords_api_client(self, selector):
try:
return _adwords_client.get(selector)
except AdwordsAPIException:
return None
提前谢谢了!
解决方案
好吧,您已经创建了一个永远不会引发的自定义异常类,要跳过所有异常,试试这个
def call_adwords_api_client(self, selector):
try:
return _adwords_client.get(selector)
except:
return None
此外,api 建议等待 30 秒后再重试。祝你好运。
推荐阅读
- flutter - Flutter如何在gridview中显示数组数据?
- css - 无法使用 flex 将 2 个图像连续放置
- google-sheets - 如果上面的单元格不为空,则条件格式化单元格
- django - GeoDjango + Postgis 缺少功能
- php - 在 WooCommerce 中以编程方式更改货币和付款方式
- javascript - 如何将力有向图重置为其原始位置?
- oracle - 单独的美分和美元值 Oracle
- sql - Postgres 使用 bigint 列加入 Json 数组
- c# - 单击按钮后如何将注意力集中在元素上
- angular - 在 RxJS 流中链接身份验证的最佳实践