mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
added dampandmouldandrepaircomments, more resilence on retries with hubspot api
This commit is contained in:
parent
acb44dc60a
commit
e1ea6f79f9
1 changed files with 7 additions and 3 deletions
|
|
@ -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)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue