details:   https://code.tryton.org/tryton/commit/3e2a195d2b33
branch:    default
user:      Cédric Krier <[email protected]>
date:      Sat Aug 15 08:03:57 2026 +0200
description:
        Raise last retry exception from JSON-RPC request

        Closes #15008
diffstat:

 tryton/tryton/jsonrpc.py |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r f1840545f4eb -r 3e2a195d2b33 tryton/tryton/jsonrpc.py
--- a/tryton/tryton/jsonrpc.py  Wed Aug 12 17:57:01 2026 +0200
+++ b/tryton/tryton/jsonrpc.py  Sat Aug 15 08:03:57 2026 +0200
@@ -294,7 +294,8 @@
 
         try:
             try:
-                for i in range(5):
+                count, retry = 0, 5
+                while True:
                     try:
                         response = self.__transport.request(
                             self.__host,
@@ -304,17 +305,21 @@
                             )
                         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:

Reply via email to