Comments (7)
Hi @SamueLacombe, thanks for the questions.
- The HTTP status code is not included in the exception, because we didn't expect it to be needed. The HTTP status code is already checked by the library to choose the type of exception and message. Do you need it for your application?
- The
should_retry
parameter is used internally when deciding whether to retry requests. The library retries failed requests, by default up to 5 times. - A few ways you could trigger errors: use an incorrect auth-key, use an invalid target or source language code, or try to translate an unsupported document type (e.g. image files).
Thanks for creating this issue; these things could be made more clear in the documentation.
from deepl-python.
Hello,
I had to implement a "Exponential Backoff" with google automl api. I was trying to implement it with deepl aswell, if ever it fail for specific reason on the server side, but without the error code, I could retry on useless errors.
I believe it's possible to get bad gateway randomly like any other API?
Best regards,
Samuel
from deepl-python.
+1 to the above, just implementing some exception handling and I think it's very different based on the type of error. e.g. for 502 Service Unavailable (also 429, maybe 456..), I would just backoff and retry later.
For 404 Not Found or 400 Bad Request, I would raise it to my Sentry because likely I'm doing something wrong and retrying will just spam your servers.
from deepl-python.
Hi Samuel, this library already retries failed requests with exponential backoff, so you might not need to implement it yourself. The function which decides whether to retry a request is http_client._should_retry()
. We retry 429 and >=500 (excluding 503), so a 502 error would be retried.
I will look into exposing the HTTP error code in exceptions, and possibly the shouldRetry
flag as well.
from deepl-python.
Thanks Daniel! Any potential ETA on this? Cheers
from deepl-python.
Hi again, sorry for the long delay. v1.12.0 adds properties should_retry
and (Optional) http_status_code
to DeepLException. Please let me know if there are any problems.
from deepl-python.
thank you!
from deepl-python.
Related Issues (20)
- [Bug] DeepL Write adds sentences describing chosen style
- DeepL documentation states ZH is supported as target for translate_docs but on execution it errors HOT 2
- translate_document_from_filepath fails to recognise XML files HOT 1
- Error: Bad request, message: Document is empty HOT 4
- [Feature Request] Make auto-retry toggleable HOT 3
- can't use my auth key, and can't sign up to the API plan for free trial HOT 4
- preserve_formatting missing in translate_document() function HOT 5
- translator.create_glossary() forces to remove regional variant HOT 3
- Translation with glossary and target "EN-GB" looses some words HOT 2
- Encoding problem when translating to french. HOT 2
- New feature : customize timeout duration HOT 2
- Glossaries HOT 1
- deepl.Formality.MORE results in untranslated text HOT 1
- Mismatch in the placement of ignore tags and lack of translation HOT 1
- The deepl.Formality is ignored
- Abnormal strings in translation results: ãã£ã£ãç§ã¡ã¡åã HOT 5
- `translate_document()` should `seek(0, 0)` the output file after being done
- Disambiguate homonyms in glossaries / provide alternative translations? HOT 3
- When translating long English fields into Chinese, the last paragraph was lost
- Glossary flexible search
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepl-python.