aboutsummaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
authorwbond <will@wbond.net>2019-09-14 05:51:45 -0400
committerwbond <will@wbond.net>2019-09-14 05:51:45 -0400
commit42bccd88cc3b73d8b1626d07305403c1d656b4d8 (patch)
tree3085b85289172082b39c06e57eeb5dc1261f6d1e /dev
parent5a4930e651fffea2d190dd56f103e7199f03394f (diff)
downloadasn1crypto-42bccd88cc3b73d8b1626d07305403c1d656b4d8.tar.gz
Limit the number of times we retry upload to codecov
Diffstat (limited to 'dev')
-rw-r--r--dev/coverage.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/dev/coverage.py b/dev/coverage.py
index 6674d26..a5b829c 100644
--- a/dev/coverage.py
+++ b/dev/coverage.py
@@ -552,7 +552,8 @@ def _do_request(method, url, headers, data=None, query_params=None, timeout=20):
stdout, stderr = _execute(
[powershell_exe, '-Command', code],
os.getcwd(),
- re.compile(r'Unable to connect to|TLS')
+ re.compile(r'Unable to connect to|TLS'),
+ 3
)
if stdout[-2:] == b'\r\n' and b'\r\n\r\n' in stdout:
# An extra trailing crlf is added at the end by powershell
@@ -582,7 +583,8 @@ def _do_request(method, url, headers, data=None, query_params=None, timeout=20):
stdout, stderr = _execute(
args,
os.getcwd(),
- re.compile(r'Failed to connect to|TLS|SSLRead|outstanding|cleanly')
+ re.compile(r'Failed to connect to|TLS|SSLRead|outstanding|cleanly'),
+ 3
)
finally:
if tempf_path and os.path.exists(tempf_path):
@@ -623,7 +625,7 @@ def _do_request(method, url, headers, data=None, query_params=None, timeout=20):
return (content_type, encoding, body)
-def _execute(params, cwd, retry=None):
+def _execute(params, cwd, retry=None, retries=0):
"""
Executes a subprocess
@@ -636,6 +638,9 @@ def _execute(params, cwd, retry=None):
:param retry:
If this string is present in stderr, or regex pattern matches stderr, retry the operation
+ :param retries:
+ An integer number of times to retry
+
:return:
A 2-element tuple of (stdout, stderr)
"""
@@ -649,13 +654,13 @@ def _execute(params, cwd, retry=None):
stdout, stderr = proc.communicate()
code = proc.wait()
if code != 0:
- if retry:
+ if retry and retries > 0:
stderr_str = stderr.decode('utf-8')
if isinstance(retry, Pattern):
if retry.search(stderr_str) is not None:
- return _execute(params, cwd, retry)
+ return _execute(params, cwd, retry, retries - 1)
elif retry in stderr_str:
- return _execute(params, cwd, retry)
+ return _execute(params, cwd, retry, retries - 1)
e = OSError('subprocess exit code for "%s" was %d: %s' % (' '.join(params), code, stderr))
e.stdout = stdout
e.stderr = stderr