Implement lab4 S3 attachments and reliability checks
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user