diff --git a/services/google/search.py b/services/google/search.py index 72dfe13b..2a6fd752 100644 --- a/services/google/search.py +++ b/services/google/search.py @@ -71,7 +71,7 @@ def scrape_content_from_url(url: str): @handle_exceptions(default_return_value=[], raise_on_error=False, api_type="google") def google_search( - base_args: BaseArgs, + base_args: BaseArgs, # pylint: disable=unused-argument query: str, num_results: int = NUM_RESULTS_DEFAULT, lang: str = "en", diff --git a/utils/handle_exceptions.py b/utils/handle_exceptions.py index 5ac47fb5..46d8e938 100644 --- a/utils/handle_exceptions.py +++ b/utils/handle_exceptions.py @@ -33,6 +33,8 @@ def wrapper(*args: Tuple[Any, ...], **kwargs: Any): except requests.exceptions.HTTPError as err: reason: str | Any = err.response.reason text: str | Any = err.response.text + status_code: int = err.response.status_code + print(f"reason: {reason}, text: {text}, status_code: {status_code}") if api_type == "github" and err.response.status_code in {403, 429}: limit = int(err.response.headers["X-RateLimit-Limit"]) @@ -65,6 +67,7 @@ def wrapper(*args: Tuple[Any, ...], **kwargs: Any): elif api_type == "google" and err.response.status_code == 429: retry_after = int(err.response.headers.get("Retry-After", 60)) + print(f"retry_after: {retry_after}") err_msg = f"Google Search Rate Limit: {func.__name__} will retry after {retry_after} seconds" logging.warning(msg=err_msg) time.sleep(retry_after)