Hello, Recently my program started running extremely slow and upon investigation I found that the '{method 'next_event' of 'grpc._cython.cygrpc.SegregatedCall' objects} was take over 5 seconds per call.
I am using the latest versions of grpc and google-ads packages. Here is an example of my code that is running and below is the output from a cProfile run that shows the issue: from google.ads.googleads.client import GoogleAdsClient from google.ads.googleads.v13.services.services.google_ads_service import pagers import logging logging.basicConfig(level=logging.INFO, format='[%(asctime)s - %(levelname)s] %(message).5000s') logging.getLogger('google.ads.googleads.client').setLevel(logging.INFO) client = GoogleAdsClient.load_from_storage("google-ads.yaml") google_ads_service = client.get_service("GoogleAdsService", version='v13') class GoogleQuery: """A class to query Google Ads API Attributes: client: An initialized GoogleAdsClient instance. mcc_id: The Google Ads MCC ID search_accounts_query: A query to return all search accounts display_accounts_query: A query to return all display accounts Methods: get_existing_search_accounts: Returns a dictionary of existing search accounts get_existing_display_accounts: Returns a dictionary of existing display accounts run_gaql_query: Runs a GAQL query and returns a Pager object """ def __init__(self): self.client = client self.mcc_id = "XXXXXXXXXX" self.search_accounts_query = """SELECT customer_client.id, customer_client.resource_name, customer_client.descriptive_name, customer_client.manager, customer_client.applied_labels FROM customer_client WHERE customer_client.manager = false AND customer_client.id IS NOT NULL AND customer_client.descriptive_name LIKE '%Search%' AND customer.status = 'ENABLED'""" @staticmethod def run_gaql_query(query: str, customer_id) -> pagers.SearchPager: """runs GAQL query through Google Ads API Args: customer_id: customer ID being queried, default is Digible MCC query: the actual GAQL query being ran Returns: Returns a pagers.SearchPager response of the raw data """ return google_ads_service.search( customer_id=customer_id, query=query ) def get_existing_search_accounts(self) -> dict: """runs GAQL query through Google Ads API Args: customer_id: customer ID being queried, default is Digible MCC Returns: Returns a dict of {digible_id, account_name} """ response = self.run_gaql_query(self.search_accounts_query, self.mcc_id) return {row.customer_client.descriptive_name[-8:]: row.customer_client.descriptive_name for row in response} gaql = GoogleQuery() gaql.get_existing_search_accounts() #cProfile results Tue May 16 13:31:28 2023 output_test.pstats 991213 function calls (973122 primitive calls) in 10.099 seconds Ordered by: internal time List reduced from 6168 to 20 due to restriction <20> ncalls tottime percall cumtime percall filename:lineno(function) 1 7.398 7.398 7.401 7.401 {method 'next_event' of 'grpc._cython.cygrpc.SegregatedCall' objects} 1118 0.441 0.000 0.441 0.000 {method 'read' of '_io.BufferedReader' objects} -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/04c4250c-84a3-461d-8add-cd0786a8f71en%40googlegroups.com.