mirror of https://github.com/tiangolo/fastapi.git
Increase retry attempts and add timeout for server check
Increased the retry attempts for server connection and added a timeout to the HTTP request.
This commit is contained in:
parent
f2687dc1bb
commit
41e55ab698
|
|
@ -25,12 +25,16 @@ process = subprocess.Popen(
|
||||||
["fastapi", "run", "docs_src/sql_databases/tutorial002.py"],
|
["fastapi", "run", "docs_src/sql_databases/tutorial002.py"],
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
for _ in range(3):
|
for _ in range(10):
|
||||||
try:
|
try:
|
||||||
response = httpx.get("http://localhost:8000/docs")
|
response = httpx.get("http://localhost:8000/docs", timeout=1)
|
||||||
|
if response.status_code == 200:
|
||||||
|
break
|
||||||
except httpx.ConnectError:
|
except httpx.ConnectError:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
break
|
else:
|
||||||
|
raise RuntimeError("Server did not start in time")
|
||||||
|
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
run(playwright)
|
run(playwright)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue