From e1ea6f79f9389f9db767bded2d3a9c36bb35508c Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 2 Apr 2026 10:19:40 +0000 Subject: [PATCH] added dampandmouldandrepaircomments, more resilence on retries with hubspot api --- etl/hubspot/hubspotClient.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/etl/hubspot/hubspotClient.py b/etl/hubspot/hubspotClient.py index 20f90944..72cf2b9c 100644 --- a/etl/hubspot/hubspotClient.py +++ b/etl/hubspot/hubspotClient.py @@ -91,14 +91,18 @@ class HubspotClient: Call fn(), retrying up to max_retries times on 429 rate-limit errors. Waits the minimal amount: the remaining interval window reported by HubSpot headers. Falls back to the full interval (10s) if headers are absent. + + Note: each HubSpot sub-module (deals, companies, etc.) ships its own ApiException + class with no shared base beyond Exception, so we detect 429s via duck-typing. """ for attempt in range(max_retries + 1): try: return fn() - except ApiException as e: - if e.status != 429 or attempt == max_retries: + except Exception as e: + status = getattr(e, "status", None) + if status != 429 or attempt == max_retries: raise - headers = e.headers or {} + headers = getattr(e, "headers", None) or {} interval_ms = int( headers.get("x-hubspot-ratelimit-interval-milliseconds", 10000) )