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 @@ enforcing the rule that setup can only run once.
from __future__ import annotations
import asyncio
from app.utils.async_utils import run_blocking
from pathlib import Path
from typing import TYPE_CHECKING
@@ -82,8 +83,8 @@ async def run_setup(
# the asyncio event loop.
password_bytes = master_password.encode()
loop = asyncio.get_running_loop()
hashed: str = await loop.run_in_executor(
None, lambda: bcrypt.hashpw(password_bytes, bcrypt.gensalt()).decode()
hashed: str = await run_blocking(
lambda: bcrypt.hashpw(password_bytes, bcrypt.gensalt()).decode()
)
await settings_repo.set_setting(db, _KEY_PASSWORD_HASH, hashed)