Add optional timeout to API, 60s default (#376)

This commit is contained in:
cybermaggedon 2025-05-08 19:00:17 +01:00 committed by GitHub
parent 9f52660a45
commit 6be0ca1990
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,7 +25,7 @@ def check_error(response):
class Api:
def __init__(self, url="http://localhost:8088/"):
def __init__(self, url="http://localhost:8088/", timeout=60):
self.url = url
@ -34,6 +34,8 @@ class Api:
self.url += "api/v1/"
self.timeout = timeout
def flow(self):
return Flow(api=self)
@ -51,7 +53,7 @@ class Api:
# print(json.dumps(request, indent=4))
# Invoke the API, input is passed as JSON
resp = requests.post(url, json=request)
resp = requests.post(url, json=request, timeout=self.timeout)
# Should be a 200 status code
if resp.status_code != 200: