You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2024/01/09 17:21:25 UTC
(couchdb) 01/02: Improve retries in dev/run cluster setup
This is an automated email from the ASF dual-hosted git repository.
rnewson pushed a commit to branch nouveau-package-2
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit f51a873deb825ab8eabc4c55d793e9819e55e707
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Sat Jan 6 16:32:29 2024 -0500
Improve retries in dev/run cluster setup
Noticed we still get connection refused errors for nouveau tests
cluster setup tests. Try to handle retries for connection errors which
are thrown not just due to a status code. After retries are exhausted,
then fail as before.
---
dev/run | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/dev/run b/dev/run
index f4b689929..078bb14b5 100755
--- a/dev/run
+++ b/dev/run
@@ -1104,17 +1104,23 @@ def try_request(
):
while True:
conn = httpclient.HTTPConnection(host, port)
- if headers is not None:
- conn.request(meth, path, body=body, headers=headers)
- else:
- conn.request(meth, path, body=body)
- resp = conn.getresponse()
- if resp.status in success_codes:
- result = (resp.status, resp.read())
- resp.close()
- return result
- elif retries <= 0:
- assert resp.status in success_codes, "%s%s" % (error, resp.read())
+ try:
+ if headers is not None:
+ conn.request(meth, path, body=body, headers=headers)
+ else:
+ conn.request(meth, path, body=body)
+ resp = conn.getresponse()
+ if resp.status in success_codes:
+ result = (resp.status, resp.read())
+ resp.close()
+ return result
+ elif retries <= 0:
+ assert resp.status in success_codes, "%s%s" % (error, resp.read())
+ except Exception as e:
+ if retries <= 0:
+ print("Connection failed %s %s" % (e, error))
+ raise e
+ print("Retrying ... %s " % e)
retries -= 1
time.sleep(retry_dt)