codeocean / codeocean-sdk-python

Code Ocean Python SDK
MIT License
3 stars 2 forks source link

Allow for retries in requests #12

Open jtyoung84 opened 2 days ago

jtyoung84 commented 2 days ago

Code Ocean REST API requests will sometimes return a 429 response code when the server is overloaded. It will be helpful if the requests can be set to automatically retry in those events or other server error events.

jtyoung84 commented 1 day ago

On second thought, it might be better to handle this user-side.

zvikagart commented 21 hours ago

I think it should be possible to configure the requests session with a retry strategy as described here: https://oxylabs.io/blog/python-requests-retry

client = CodeOcean(...)
retry = Retry(...)
adapter = HTTPAdapter(max_retries=retry)
client.session.mount(client.domain, adapter)