From 5a18341cdf105c5dac0ad127e312b95283c913a4 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Wed, 22 Jul 2026 16:52:50 +0200 Subject: [PATCH] pw: retry on 502 and 504 errors Recently, some services have failed due to a 504 error from Patchwork when retrieving a JSON with: self._request(...).json() or: self._get(...).json() In both cases, the logs were showing: **** Response **** Response data 504 Gateway Time-out

504 Gateway Time-out

Ask the requests lib to retry on 502 and 504 for us, that seems the easiest (if this works as expected). Signed-off-by: Matthieu Baerts --- pw/patchwork.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pw/patchwork.py b/pw/patchwork.py index c08e07cd..5f2472b7 100644 --- a/pw/patchwork.py +++ b/pw/patchwork.py @@ -31,7 +31,8 @@ class PatchworkPostException(Exception): class Patchwork(object): def __init__(self, config): self._session = requests.Session() - retry = Retry(connect=10, backoff_factor=1) + retry = Retry(connect=10, status=10, status_forcelist={502, 504}, + backoff_factor=1) adapter = HTTPAdapter(max_retries=retry) self._session.mount('http://', adapter) self._session.mount('https://', adapter)