mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-21 11:11:03 +02:00
Add optional timeout to API, 60s default
This commit is contained in:
parent
9e9b21068c
commit
7feb825887
1 changed files with 4 additions and 2 deletions
|
|
@ -25,7 +25,7 @@ def check_error(response):
|
||||||
|
|
||||||
class Api:
|
class Api:
|
||||||
|
|
||||||
def __init__(self, url="http://localhost:8088/"):
|
def __init__(self, url="http://localhost:8088/", timeout=60):
|
||||||
|
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
|
|
@ -34,6 +34,8 @@ class Api:
|
||||||
|
|
||||||
self.url += "api/v1/"
|
self.url += "api/v1/"
|
||||||
|
|
||||||
|
self.timeout = timeout
|
||||||
|
|
||||||
def flow(self):
|
def flow(self):
|
||||||
return Flow(api=self)
|
return Flow(api=self)
|
||||||
|
|
||||||
|
|
@ -51,7 +53,7 @@ class Api:
|
||||||
# print(json.dumps(request, indent=4))
|
# print(json.dumps(request, indent=4))
|
||||||
|
|
||||||
# Invoke the API, input is passed as JSON
|
# 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
|
# Should be a 200 status code
|
||||||
if resp.status_code != 200:
|
if resp.status_code != 200:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue