Comments (4)
Hey,
Thanks for reaching out, and apologies for the late response.
I'm wondering if this is due to our built-in retries.
Can you try altering the retry settings; that may lower the wait time that causes the gunicorn timeout.
For reference, the retry settings (with default values) at the client level are:
klaviyo = KlaviyoAPI("YOUR_API_KEY_HERE", max_delay=60, max_retries=3)
where max_delay
is the total delay across all retry attempts.
If you'd like to turn off retries altogether and implement your own error handling, you can set:
klaviyo = KlaviyoAPI("YOUR_API_KEY_HERE", max_delay=0, max_retries=0)
from klaviyo-api-python.
hey @jon-batscha - qq regarding retries mechanism - on what status codes does the library makes retries?
we occasionally get 502 responses (like once a day, usually multiple of those at the same time) from the klaviyo api, and not sure if the client library makes a retry on those.
seems to us that it does not and wanted to double check that with you...
also, we would like to use the _request_timeout
variable to use that and i'm not sure how does that combines with the max_delay
and max_retry
when setting the API class.
last time we saw this was around 23:00 UTC time Aug 28th..
example of error response we see in our logs (seems also something with cloudflare?)
from klaviyo-api-python.
Hi Oded,
Thanks for reaching out, great question!
I actually just updated the retry logic in today’s release (thanks to your feedback), so what I’ll describe below applies to versions 5.3.0 and later: we retry on the following error codes:
_STATUS_CODE_CONNECTION_RESET_BY_PEER = 104
_STATUS_CODE_TOO_MANY_REQUESTS = 429
_STATUS_CODE_SERVICE_UNAVAILABLE = 503
_STATUS_CODE_GATEWAY_TIMEOUT = 504
_STATUS_CODE_A_TIMEOUT_OCCURED = 524
NOTE: we do not retry on 502 errors, as those are not guaranteed to be transient, and so retrying on those could hold up jobs. That said, our API team is aware of the occasional 502s and is working to fix this on our end (at the API-level).
In terms of the retry logic: we currently take the following 2 params:
max_delay
max_retries
We retry up to max_retries
, using the following algorithm: wait_random_exponential
The algorithm starts with a 1 second wait, and at each retry, doubles the wait time, up to max_delay
Given this updated logic, we now recommend the following default values (now reflected in our defaults/readme:
max_delay = 60
max_retries = 7
With this setting, the SDK will behave as follows:
- First request, no delay
- Second request, wait 1 second before retrying
- … wait 2 seconds before retrying
- … wait 4 seconds …
- … 8 seconds …
- … 16 seconds …
- … 32 seconds …
At this point, if no success, we’ll stop retrying.
You can find the code that implements retry logic and sets retry codes here.
Hopefully this answers your question. Please do not hesitate to reach out if you run into any further issues.
(I also received your email yesterday, will follow up on the questions you sent over there in a bit)
from klaviyo-api-python.
Related Issues (20)
- How to use "page[size]" parameter? HOT 1
- how to avoid error when making many calls? HOT 1
- No Page Size in "get_profiles" HOT 1
- Missing positional argument "id" even though it is provided HOT 2
- Rendering templates HOT 1
- Feature request: Bulk setting/unsetting of user properties HOT 4
- fields[profile] parameter not working HOT 2
- permissions issue with getting lists + campaign audience type (List\Segment) HOT 1
- klaviyo.Templates.get_template return error 500 HOT 3
- _from_openapi_data() missing 1 required positional argument: 'name' on create event HOT 2
- _from_openapi_data() missing 1 required positional argument: 'name' on create event HOT 1
- Need basic documentation on how Track and Identify map into this new API HOT 1
- bug in profile unset property functionality HOT 2
- 400 HTTP errors with get_events() per specific metric ids HOT 4
- Pydantic v2 compatibility HOT 10
- Flows pagination not possible HOT 5
- Templates Pagination not functioning HOT 6
- Klaviyo profile unable to subscribe: due to HTTPSConnectionPool HOT 2
- "Invalid cursor provided" Error for "get_events()" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from klaviyo-api-python.