Skip to content

Commit 9b353fc

Browse files
Limit document status update wait time to 60 seconds, and log wait times
1 parent 2266d4e commit 9b353fc

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8+
## [Unreleased]
9+
### Added
10+
### Changed
11+
* Limit document status update wait time to 60 seconds, and log wait times.
12+
### Deprecated
13+
### Removed
14+
### Fixed
15+
### Security
16+
17+
818
## [1.3.0] - 2021-11-15
919
### Added
1020
* Add glossary support for document translation.
@@ -102,6 +112,7 @@ Version increased to avoid conflicts with old packages on PyPI.
102112
Initial version.
103113

104114

115+
[Unreleased]: https://github.com/DeepLcom/deepl-python/compare/v1.3.0...HEAD
105116
[1.3.0]: https://github.com/DeepLcom/deepl-python/compare/v1.2.1...v1.3.0
106117
[1.2.1]: https://github.com/DeepLcom/deepl-python/compare/v1.2.0...v1.2.1
107118
[1.2.0]: https://github.com/DeepLcom/deepl-python/compare/v1.1.3...v1.2.0

deepl/translator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,12 @@ def translate_document(
820820
try:
821821
status = self.translate_document_get_status(handle)
822822
while status.ok and not status.done:
823-
secs = (status.seconds_remaining or 0) / 2 + 1
823+
secs = (status.seconds_remaining or 0) / 2.0 + 1.0
824+
secs = max(1.0, min(secs, 60.0))
825+
util.log_info(
826+
f"Rechecking document translation status "
827+
f"after sleeping for {secs:.3f} seconds."
828+
)
824829
time.sleep(secs)
825830
status = self.translate_document_get_status(handle)
826831

0 commit comments

Comments
 (0)