Standardize async offloading behind shared executor helper

This commit is contained in:
2026-04-11 20:40:08 +02:00
parent ae81a8f5be
commit cd69550053
13 changed files with 199 additions and 101 deletions

View File

@@ -8,6 +8,7 @@ survive server restarts.
from __future__ import annotations
import asyncio
from app.utils.async_utils import run_blocking
import hashlib
import hmac
import secrets
@@ -72,9 +73,7 @@ async def _check_password(plain: str, hashed: str) -> bool:
plain_bytes = plain.encode()
hashed_bytes = hashed.encode()
loop = asyncio.get_running_loop()
return await loop.run_in_executor(
None, lambda: bool(bcrypt.checkpw(plain_bytes, hashed_bytes))
)
return await run_blocking(lambda: bool(bcrypt.checkpw(plain_bytes, hashed_bytes)))
async def login(