35 lines
813 B
Python
35 lines
813 B
Python
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import time
|
|
|
|
from app.errors import ApiError
|
|
from app.storage import check_storage
|
|
|
|
|
|
async def main() -> None:
|
|
deadline = time.monotonic() + 90
|
|
|
|
while True:
|
|
try:
|
|
await check_storage()
|
|
except ApiError:
|
|
if time.monotonic() >= deadline:
|
|
raise SystemExit(
|
|
"S3 readiness failed: bucket unavailable "
|
|
"or API credentials rejected"
|
|
) from None
|
|
|
|
print("Waiting for S3 bucket...", flush=True)
|
|
await asyncio.sleep(2)
|
|
else:
|
|
print(
|
|
"S3 bucket is accessible with API credentials",
|
|
flush=True,
|
|
)
|
|
return
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|