File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 6
6
from typing import AsyncIterator
7
7
8
8
from fastapi import FastAPI , HTTPException
9
+ from starlette .concurrency import run_in_threadpool
9
10
from starlette .requests import Request
10
11
from starlette .responses import JSONResponse
11
12
19
20
async def put_images_to_s3 () -> None :
20
21
file_sm = StorageManager ()
21
22
s3_sm = S3StorageManager ()
22
- all_uuids = s3_sm .list_uuids ( )
23
+ all_uuids = await run_in_threadpool ( s3_sm .list_uuids )
23
24
for file1 in os .listdir (settings .upload_folder ):
24
25
await asyncio .sleep (0 )
25
26
path1 = os .path .join (settings .upload_folder , file1 )
@@ -37,7 +38,7 @@ async def put_images_to_s3() -> None:
37
38
@asynccontextmanager
38
39
async def lifespan (app : FastAPI ) -> AsyncIterator :
39
40
# noinspection PyAsyncCall
40
- # asyncio.create_task(put_images_to_s3())
41
+ asyncio .create_task (put_images_to_s3 ())
41
42
yield
42
43
43
44
You can’t perform that action at this time.
0 commit comments