python - Google.Ads.GoogleAds.E​​xamples 返回截止日期已超过

标签 python google-ads-api

我正在尝试运行第一个示例:通过 python sdk(广告 api,而不是 adwords)获取广告系列。 我收到一个没有描述如何解决问题的错误:google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded

"""This example illustrates how to get all campaigns.

To add campaigns, run add_campaigns.py.
"""

from __future__ import absolute_import

import argparse
import six
import sys

import google.ads.google_ads.client


_DEFAULT_PAGE_SIZE = 10


def main(client, customer_id, page_size):
    ga_service = client.get_service('GoogleAdsService', version='v1')

    query = ('SELECT campaign.id, campaign.name FROM campaign '
             'ORDER BY campaign.id')

    results = ga_service.search(customer_id, query=query, page_size=page_size)

    try:
        for row in results:
            print('Campaign with ID %d and name "%s" was found.'
                  % (row.campaign.id.value, row.campaign.name.value))
    except google.ads.google_ads.errors.GoogleAdsException as ex:
        print('Request with ID "%s" failed with status "%s" and includes the '
              'following errors:' % (ex.request_id, ex.error.code().name))
        for error in ex.failure.errors:
            print('\tError with message "%s".' % error.message)
            if error.location:
                for field_path_element in error.location.field_path_elements:
                    print('\t\tOn field: %s' % field_path_element.field_name)
        sys.exit(1)


if __name__ == '__main__':
    google_ads_client = (google.ads.google_ads.client.GoogleAdsClient
                         .load_from_storage("google-ads.yaml"))
    main(google_ads_client, "customer_id", _DEFAULT_PAGE_SIZE)

得到错误:

Traceback (most recent call last):
  File "c:/PythonProjects/google_ads_api_test/google-ads-python-master/google-ads-python-master/examples/basic_operations/get_campaigns.py", line 68, in <module>
    main(google_ads_client, "customer_id", _DEFAULT_PAGE_SIZE)
  File "c:/PythonProjects/google_ads_api_test/google-ads-python-master/google-ads-python-master/examples/basic_operations/get_campaigns.py", line 40, in main
    for row in results:
  File "C:\Anaconda3\lib\site-packages\google\api_core\page_iterator.py", line 204, in _items_iter
    for page in self._page_iter(increment=False):
  File "C:\Anaconda3\lib\site-packages\google\api_core\page_iterator.py", line 235, in _page_iter
    page = self._next_page()
  File "C:\Anaconda3\lib\site-packages\google\api_core\page_iterator.py", line 526, in _next_page
    response = self._method(self._request)
  File "C:\Anaconda3\lib\site-packages\google\api_core\gapic_v1\method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\google\api_core\retry.py", line 270, in retry_wrapped_func
    on_error=on_error,
  File "C:\Anaconda3\lib\site-packages\google\api_core\retry.py", line 179, in retry_target
    return target()
  File "C:\Anaconda3\lib\site-packages\google\api_core\timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\google\api_core\grpc_helpers.py", line 59, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded

调用有问题吗?

最佳答案

我相信您只需要在配置中增加超时值即可。

关于python - Google.Ads.GoogleAds.E​​xamples 返回截止日期已超过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55348984/

相关文章:

javascript - 特定时间后的转化跟踪

python - 如何将两个日期列表合并为一系列日期间隔?

python - 使用另一个名称将文件复制到同一目录

python - 尝试使用 pip 安装 pandas 时权限被拒绝

reactjs - 注册时运行 Google 广告转化代码,ReactJS

google-ads-api - 来自 Gclid 的 Adwords API 每次点击费用

javascript - AdWords 脚本无法使用 Ids 功能找到

python - 无法抓取 Google Adsense

python - SimpleITK 的 sudo easy_install 没那么容易

python - 为什么 `zip` 似乎消耗了 `groupby` 可迭代对象?