Skip to content

Commit e6e0342

Browse files
committed
switching on copying task
1 parent de93e21 commit e6e0342

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/main.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import AsyncIterator
77

88
from fastapi import FastAPI, HTTPException
9+
from starlette.concurrency import run_in_threadpool
910
from starlette.requests import Request
1011
from starlette.responses import JSONResponse
1112

@@ -19,7 +20,7 @@
1920
async def put_images_to_s3() -> None:
2021
file_sm = StorageManager()
2122
s3_sm = S3StorageManager()
22-
all_uuids = s3_sm.list_uuids()
23+
all_uuids = await run_in_threadpool(s3_sm.list_uuids)
2324
for file1 in os.listdir(settings.upload_folder):
2425
await asyncio.sleep(0)
2526
path1 = os.path.join(settings.upload_folder, file1)
@@ -37,7 +38,7 @@ async def put_images_to_s3() -> None:
3738
@asynccontextmanager
3839
async def lifespan(app: FastAPI) -> AsyncIterator:
3940
# noinspection PyAsyncCall
40-
# asyncio.create_task(put_images_to_s3())
41+
asyncio.create_task(put_images_to_s3())
4142
yield
4243

4344

0 commit comments

Comments
 (0)