mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 00:46:22 +02:00
Add optional timeout to API, 60s default (#376)
This commit is contained in:
parent
9f52660a45
commit
6be0ca1990
1 changed files with 4 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue