glucinater
glucinater11mo ago

How to avoid "connection reset by peer" exceptions when using python api?

I am currently trying to run a python script that does about 7k jobs that are decently bandwidth intensive. Yesterday about halfway through the job I got a "connection reset by peer" error message from the client which ended the job prematurely (also costing me a lot of bandwidth). How do I avoid getting this error?
4 Replies
ballingt
ballingt11mo ago
@glucinater This is a network error, something you can do now is catch this error (by importing it from the requests library) and retry; the Python http client currently contains no retries. In a week or so there will be an upgrade to the Python client to use the WebSocket in most situations which has automatic retries and shouldn't be as susceptible to this kind of error.
glucinater
glucinaterOP11mo ago
Do repeated requests cause this error or is it random?
ballingt
ballingt11mo ago
This isn't a "backoff" or rate limit exceeded sort of error, repeated requests should not cause it except that it's something that sounds like it's happening ever 1/100 or 1/1000 requests or so requests so making more requests will make you see it more.
glucinater
glucinaterOP11mo ago
Gotcha, thanks for the help!

Did you find this page helpful?