Skip to content

Commit 8914916

Browse files
committed
docs: Document HTTP client config
1 parent 21b7d55 commit 8914916

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
* New language available: Arabic (`'ar'`). Add language code constants and tests.
1111

1212
Note: older library versions also support the new language, this update only adds new code constants.
13+
* Added a section in the readme on how to configure retry options in `http_client.py`
1314

1415

1516
## [1.17.0] - 2024-02-06

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,24 @@ translator = deepl.Translator(..., verify_ssl=False)
522522
This option is passed to the underlying `requests` session as the `verify`
523523
option, see the [documentation for requests][requests-verify-ssl-docs].
524524

525+
#### Configure automatic retries
526+
527+
This SDK will automatically retry failed HTTP requests (if the failures could
528+
be transient, e.g. a HTTP 429 status code). This behaviour can be configured
529+
in `http_client.py`, for example by default the number of retries is 5. This
530+
can be changed to 3 as follows:
531+
532+
```python
533+
import deepl
534+
535+
deepl.http_client.max_network_retries = 3
536+
t = deepl.Translator(...)
537+
t.translate_text(...)
538+
```
539+
540+
You can configure the timeout `min_connection_timeout` the same way, as well
541+
as set a custom `user_agent`, see the next section.
542+
525543
#### Anonymous platform information
526544

527545
By default, we send some basic information about the platform the client library is running on with each request, see [here for an explanation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent). This data is completely anonymous and only used to improve our product, not track any individual users. If you do not wish to send this data, you can opt-out when creating your `deepl.Translator` object by setting the `send_platform_info` flag like so:

0 commit comments

Comments
 (0)