From 87e7fc92f6d277fabae6646235cec4361e241961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 15 Aug 2026 08:03:57 +0200 Subject: [PATCH] Raise last retry exception from JSON-RPC request Closes #15008 (grafted from 3e2a195d2b333fda531f719c4b6c69a7c5f2e1c0) --HG-- branch : 8.0 --- tryton/tryton/jsonrpc.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tryton/tryton/jsonrpc.py b/tryton/tryton/jsonrpc.py index 898800ddeb..d84287394a 100644 --- a/tryton/tryton/jsonrpc.py +++ b/tryton/tryton/jsonrpc.py @@ -294,7 +294,8 @@ class ServerProxy(xmlrpc.client.ServerProxy): try: try: - for i in range(5): + count, retry = 0, 5 + while True: try: response = self.__transport.request( self.__host, @@ -304,17 +305,21 @@ class ServerProxy(xmlrpc.client.ServerProxy): ) break except xmlrpc.client.ProtocolError as e: - if e.errcode == HTTPStatus.SERVICE_UNAVAILABLE: + if (e.errcode == HTTPStatus.SERVICE_UNAVAILABLE + and count < retry): + count += 1 try: - delay = int(e.headers.get('Retry-After', i)) + delay = int( + e.headers.get('Retry-After', count)) except ValueError: if isinstance( e.errcode, HTTPStatus.GATEWAY_TIMEOUT): # Do not retry on timeout without delay raise - delay = i + delay = count delay = min(delay, 10) time.sleep(delay) + continue else: raise except (socket.error, http.client.HTTPException) as v: