mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-17 09:11:03 +02:00
Add debug to endpoint
This commit is contained in:
parent
1b9c6be4fc
commit
20201b3898
1 changed files with 10 additions and 0 deletions
|
|
@ -62,6 +62,8 @@ class ServiceEndpoint:
|
||||||
|
|
||||||
id = str(uuid.uuid4())
|
id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
print(request.path, "...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ht = request.headers["Authorization"]
|
ht = request.headers["Authorization"]
|
||||||
tokens = ht.split(" ", 2)
|
tokens = ht.split(" ", 2)
|
||||||
|
|
@ -78,23 +80,31 @@ class ServiceEndpoint:
|
||||||
|
|
||||||
data = await request.json()
|
data = await request.json()
|
||||||
|
|
||||||
|
print(data)
|
||||||
|
|
||||||
q = await self.sub.subscribe(id)
|
q = await self.sub.subscribe(id)
|
||||||
|
|
||||||
await self.pub.send(
|
await self.pub.send(
|
||||||
id,
|
id,
|
||||||
self.to_request(data),
|
self.to_request(data),
|
||||||
)
|
)
|
||||||
|
print("Request sent")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = await asyncio.wait_for(q.get(), self.timeout)
|
resp = await asyncio.wait_for(q.get(), self.timeout)
|
||||||
except:
|
except:
|
||||||
raise RuntimeError("Timeout waiting for response")
|
raise RuntimeError("Timeout waiting for response")
|
||||||
|
|
||||||
|
print("Response got")
|
||||||
|
|
||||||
if resp.error:
|
if resp.error:
|
||||||
|
print("Error")
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
{ "error": resp.error.message }
|
{ "error": resp.error.message }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print("Send response")
|
||||||
|
|
||||||
return web.json_response(
|
return web.json_response(
|
||||||
self.from_response(resp)
|
self.from_response(resp)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue