From 94485d665f2a50ee02dd2b8cfd75c8f8c60b4462 Mon Sep 17 00:00:00 2001 From: Matthieu Baerts Date: Tue, 14 Jul 2026 23:24:28 +0200 Subject: [PATCH] pw: retry POST actions 3 times instead of 1 More errors are visible recently. The last one got two 504 errors in a row. It seems better to retry 2 times more with an exponential back-off, so retrying for maximum 3 minutes 30 + the timeout period. Signed-off-by: Matthieu Baerts --- pw/patchwork.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pw/patchwork.py b/pw/patchwork.py index c08e07cd..6ee16d74 100644 --- a/pw/patchwork.py +++ b/pw/patchwork.py @@ -226,10 +226,13 @@ def post_check(self, patch, name, state, url, desc): } r = self._post(f'patches/{patch}/checks/', headers=headers, data=data) - if r.status_code == 502 or r.status_code == 504: - # Timeout, let's wait 30 sec and retry, POST isn't retried by the lib. - time.sleep(30) - r = self._post(f'patches/{patch}/checks/', headers=headers, data=data) + for retry in range(3): + if r.status_code == 502 or r.status_code == 504: + # Timeout, let's wait 30 sec and retry, POST isn't retried by the lib. + time.sleep(30 << retry) + r = self._post(f'patches/{patch}/checks/', headers=headers, data=data) + else: + break if r.status_code != 201: raise PatchworkPostException(r)