diff options
author | Linus Nordberg <linus@nordu.net> | 2017-02-08 10:38:17 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-02-08 10:38:17 +0100 |
commit | c1ac7daa7589346f7308e5399452e3a7993a1b85 (patch) | |
tree | 70a43b0ef3f28fd8396823fa927038b8ece676de /tools/certtools.py | |
parent | b188fcc29c3df97978e5da4a87b946b300d79932 (diff) |
Have loginfo.py tolerate 500 for a while when waiting for STH.
Diffstat (limited to 'tools/certtools.py')
-rw-r--r-- | tools/certtools.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/certtools.py b/tools/certtools.py index f5482cb..7a5f9fc 100644 --- a/tools/certtools.py +++ b/tools/certtools.py @@ -18,6 +18,7 @@ import shutil import requests import warnings import logging +from time import sleep from certkeys import publickeys @@ -131,6 +132,15 @@ def get_sth(baseurl): result.raise_for_status() return result.json() +def get_sth_retry(baseurl, tries=1): + for i in range(tries): + try: + return get_sth(baseurl) + except requests.exceptions.HTTPError, e: + if e.response.status_code == 500: + sleep(1) + raise e + def get_proof_by_hash(baseurl, hash, tree_size): params = {"hash":base64.b64encode(hash), "tree_size":tree_size} |