python httpx :)
Some checks failed
checks-impure / test (pull_request) Successful in 33s
checks / test (pull_request) Failing after 3m23s

This commit is contained in:
Georg-Stahn
2023-12-04 20:44:32 +01:00
parent 086966918a
commit 737fff1c21

View File

@@ -1,7 +1,7 @@
import time import time
from typing import List, Optional from typing import List, Optional
from httpx import AsyncClient import httpx
from fastapi import APIRouter, BackgroundTasks, Depends from fastapi import APIRouter, BackgroundTasks, Depends
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
@@ -209,10 +209,12 @@ async def attach_entity(entity_did: str, db: Session) -> None:
try: try:
while db_entity.attached: while db_entity.attached:
#query status endpoint #query status endpoint
async with AsyncClient(app=app, base_url=f"http://{db_entity.ip}") as ac: # https://www.python-httpx.org/
response = await ac.get("/") response = httpx.get(f"http://{db_entity.ip}", timeout=2)
# test with: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo '<html>test</html>'; } | nc -l 5556; done print(response)
#except not reached set false # test with:
# while true ; do printf 'HTTP/1.1 200 OK\r\n\r\ncool, thanks' | nc -l -N localhost 5555 ; done
# except not reached set false
time.sleep(1) time.sleep(1)
except Exception as e: except Exception as e:
raise e raise e