Skip to main content

Hi, I’m sending a massive number(over 100k) of custom properties through a for loop and python sdk, but this took too much time and got ConnectionResetError(104, 'Connection reset by peer'). I know this is due to some protection from the server, but I don’t know in what condition will trigger this error. So I’m wondering the best practice if I have a lot of data to send.

 

Here’s what I have tried:

  1. sent the data with an array like this, but got a 500 internal server error:
{'token': 'mykey',
'properties': [{'$email': 'e1', 'mylabel': 0.0014},
{'$email': 'e2', 'mylabel': 0.0002}]}
  1. iterated all my data, but somehow got ConnectionResetError:
from klaviyo_sdk import Client
client = Client(private_key, max_delay=5, max_retries=2)

succeed_emails = []
failed_emails = []
for email, label in zip(emails, labels):
data = {
"token": private_key,
"properties": {
"$email": email,
"mylabel": label
}
}
res = client.TrackIdentify.identify_post(data=data)
if res == "0":
failed_emails.append(email)
else:
succeed_emails.append(email)

By the way, this is probably related to this topic.

Thank you!

Hi @8ndpoint,

Thanks for sharing this question with us.

I’ve requested some feedback from our engineering team to get their view on this as well. I’ll post an update when I have one.

Thanks for being a community member.


I followed the suggestion from the team and it worked, just refreshing client before every request:

from klaviyo_sdk import Client

for email, label in zip(emails, labels):
client = Client(private_key, max_delay=5, max_retries=2)
data = {
"token": private_key,
"properties": {
"$email": email,
"mylabel": label
}
}
res = client.TrackIdentify.identify_post(data=data)

Thanks for quick response!