Google.Ads.GoogleAds.E​​xamples 返回 Deadline Exceeded

Posted

技术标签:

【中文标题】Google.Ads.GoogleAds.E​​xamples 返回 Deadline Exceeded【英文标题】:Google.Ads.GoogleAds.Examples return Deadline Exceeded 【发布时间】:2019-03-26 02:25:18 【问题描述】:

我正在尝试运行第一个示例:Get Campaigns,通过 python sdk(ads 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

电话有问题吗?

【问题讨论】:

【参考方案1】:

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

【讨论】:

以上是关于Google.Ads.GoogleAds.E​​xamples 返回 Deadline Exceeded的主要内容,如果未能解决你的问题,请参考以下文章

x=x+=x-=x-x;

为啥 ('x',) 中的 'x' 比 'x' == 'x' 快?

是∃x(P(x))是∃x(x∈S∧P(x))还是∃x(x∈S→P(x))的缩写?

python视频b'\x1aE\xdf\xa3\x01\x00\x00\x00\x00\x00\x00\

二进制数组在 C# 中将映射缩减为矩形

springboot redistemplate值有 x00数据