deepl-python icon indicating copy to clipboard operation
deepl-python copied to clipboard

New feature : customize timeout duration

Open louisgaume opened this issue 2 years ago • 2 comments

👋 Hello, we're super happy with this nice SDK !

We're just missing a small feature that would help us improving our performance. We would like to have the ability to customize the timeout of the API call being made. Customizing this parameter at a global level would be fine (for example like it's done within the PHP SDK)

If you're accepting this, we can provide a PR for this !

Let me know if you guys need anything ! Thanks in advance 😄

louisgaume avatar Dec 19 '23 16:12 louisgaume

Hi @louisgaume , there is some functionality for this already, does it not cover your use case? You can do the following

import deepl
deepl.http_client.min_connection_timeout = 5.0
translator = deepl.Translator('my_auth_key')  # Will use 5 second timeout

Please note that the library uses exponential backoff, so each consecutive retry will wait for longer - probably easiest to check the code to see what exactly happens under the hood.

See also this issue. This functionality is a bit hidden, we should definitely document it better, sorry. If it doesn't cover your use case, please elaborate.

JanEbbing avatar Jan 02 '24 13:01 JanEbbing

Hello ! Thanks for your reply, this might do the job for us in fact! Didn't know we could change this parameter this way. :) I'll take a look again at the code deeply to see how is it working under the hood.

Thanks again :)

louisgaume avatar Jan 04 '24 11:01 louisgaume