Skip to content

Commit 551f55f

Browse files
authored
Merge pull request #49 from adobe-apiplatform/v2
prepare for 2.5.2 enhancement release (better logging related to #47).
2 parents 5c77ab7 + c7645a2 commit 551f55f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

HISTORY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,12 @@ Bug fix release:
9292

9393
* [Issue 47](https://github.com/adobe-apiplatform/umapi-client.py/issues/47)
9494
* When an immediate retry was done due to a timeout, there was a logging error.
95+
96+
### Version 2.5.2
97+
98+
Enhancement release:
99+
100+
* (No Issue)
101+
* Read the wall clock to return an accurate "total time" in the `UnavailableError` (and associated logging).
102+
103+

umapi_client/connection.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(self,
8888
:param retry_max_attempts: How many times to retry on temporary errors
8989
:param retry_first_delay: The time to delay first retry (grows exponentially from there)
9090
:param retry_random_delay: The max random delay to add on each exponential backoff retry
91-
:param timeout_seconds: How many seconds to wait for server response (default=60, <= 0 or None means forever)
91+
:param timeout_seconds: How many seconds to wait for server response (<= 0 or None means forever)
9292
:param throttle_actions: Max number of actions to pack into a single call
9393
:param throttle_commands: Max number of commands allowed in a single action
9494
:param user_agent: (optional) string to use as User-Agent header (umapi-client/version data will be added)
@@ -381,7 +381,7 @@ def call():
381381
def call():
382382
return self.session.get(self.endpoint + path, auth=self.auth, timeout=self.timeout)
383383

384-
total_time = 0
384+
start_time = time()
385385
result = None
386386
for num_attempts in range(1, self.retry_max_attempts + 1):
387387
try:
@@ -412,7 +412,6 @@ def call():
412412
else:
413413
raise ServerError(result)
414414
except requests.Timeout:
415-
total_time += int(self.timeout)
416415
if self.logger: self.logger.warning("UMAPI connection timeout...(%d seconds on try %d)",
417416
self.timeout, num_attempts)
418417
retry_wait = 0
@@ -421,9 +420,9 @@ def call():
421420
if retry_wait > 0:
422421
if self.logger: self.logger.warning("Next retry in %d seconds...", retry_wait)
423422
sleep(retry_wait)
424-
total_time += retry_wait
425423
else:
426424
if self.logger: self.logger.warning("Immediate retry...")
425+
total_time = int(time() - start_time)
427426
if self.logger: self.logger.error("UMAPI timeout...giving up after %d attempts (%d seconds).",
428427
self.retry_max_attempts, total_time)
429428
raise UnavailableError(self.retry_max_attempts, total_time, result)

umapi_client/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21-
__version__ = "2.5.1"
21+
__version__ = "2.5.2"

0 commit comments

Comments
 (0)