Standardize async offloading behind shared executor helper
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user