mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +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.
|
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.
|
Waits the minimal amount: the remaining interval window reported by HubSpot headers.
|
||||||
Falls back to the full interval (10s) if headers are absent.
|
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):
|
for attempt in range(max_retries + 1):
|
||||||
try:
|
try:
|
||||||
return fn()
|
return fn()
|
||||||
except ApiException as e:
|
except Exception as e:
|
||||||
if e.status != 429 or attempt == max_retries:
|
status = getattr(e, "status", None)
|
||||||
|
if status != 429 or attempt == max_retries:
|
||||||
raise
|
raise
|
||||||
headers = e.headers or {}
|
headers = getattr(e, "headers", None) or {}
|
||||||
interval_ms = int(
|
interval_ms = int(
|
||||||
headers.get("x-hubspot-ratelimit-interval-milliseconds", 10000)
|
headers.get("x-hubspot-ratelimit-interval-milliseconds", 10000)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue