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