Add optional timeout to API, 60s default

This commit is contained in:
Cyber MacGeddon 2025-05-08 18:59:41 +01:00
parent 9e9b21068c
commit 7feb825887

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: