From 39db63543cbf382748372f14ab365f89ea661c3e Mon Sep 17 00:00:00 2001 From: Dave Thomas Date: Mon, 14 Oct 2024 13:42:28 -0400 Subject: [PATCH] Update qs_client.py added timeout --- quantastor/qs_client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quantastor/qs_client.py b/quantastor/qs_client.py index dabdd51..0e0761e 100755 --- a/quantastor/qs_client.py +++ b/quantastor/qs_client.py @@ -21,11 +21,12 @@ class QuantastorClient(object): _username = "" _password = "" _cert = "" - def __init__(self, hostname="", username="", password="", cert=""): + def __init__(self, hostname="", username="", password="", cert="", timeout=None): self._hostname = hostname self._username = username self._password = password self._cert = cert + self._timeout = timeout if environ.get('QS_HOSTNAME') and hostname == "": @@ -53,7 +54,7 @@ def make_call(self, api, payload): if not path.exists(self._cert) or not self._cert: print ("Warning - SSL certificate path: '" + str(self._cert) + "' either doesn't exist, or was not given. HTTPS request cannot be verified.") certPath = False - r = requests.get(strURL, params=payload, verify=certPath, auth=self._auth) + r = requests.get(strURL, params=payload, verify=certPath, auth=self._auth, timeout=self._timeout) if r.status_code != 200: raise Exception("Failed to make a request '" + api + "' payload '" + str(payload) + "' status code = " + str(r.status_code) + "strUrl " + strURL) jsonOutput = r.json()