wrap sync call to asyncio.thread

This commit is contained in:
austnv
2026-06-14 23:25:51 +03:00
parent c4eb0ac0e5
commit 8e2f7d9d03
+2 -1
View File
@@ -1,6 +1,7 @@
from fastapi import APIRouter
import aiofiles
import json
import asyncio
from async_lru import alru_cache
router = APIRouter(prefix='/api/v1', tags=['tariffs'])
@@ -9,7 +10,7 @@ router = APIRouter(prefix='/api/v1', tags=['tariffs'])
async def get_tariffs():
async with aiofiles.open('data/tariffs.json', 'r', encoding='utf-8') as f:
content = await f.read()
return json.loads(content)
return await asyncio.to_thread(json.loads(content))
@router.get('/tariffs')
async def get_tariffs():