From 2a7766d206c0340df47ed2833bf18385c3753d47 Mon Sep 17 00:00:00 2001 From: Lukas Date: Tue, 14 Apr 2026 13:54:47 +0200 Subject: [PATCH] Wrap blocking mkdir() calls in run_blocking for async startup and setup --- Docs/Tasks.md | 2 ++ backend/app/services/setup_service.py | 2 +- backend/app/startup.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Docs/Tasks.md b/Docs/Tasks.md index bcac6a1..5d0c271 100644 --- a/Docs/Tasks.md +++ b/Docs/Tasks.md @@ -54,6 +54,8 @@ Any user action that exercises an error path on the `/config/global`, `/config/r ### TASK-02 — Wrap blocking `mkdir()` calls in `run_blocking()` 🔴 +**Status:** Completed ✅ + **Where:** - `backend/app/services/setup_service.py` — line 178, inside `async def _ensure_database_initialized()` - `backend/app/startup.py` — line 73, inside `async def startup_shared_resources()` diff --git a/backend/app/services/setup_service.py b/backend/app/services/setup_service.py index 6e45730..230c715 100644 --- a/backend/app/services/setup_service.py +++ b/backend/app/services/setup_service.py @@ -175,7 +175,7 @@ async def _ensure_database_initialized(database_path: str) -> bool: parent_dir = database_path_obj.parent try: - parent_dir.mkdir(parents=True, exist_ok=True) + await run_blocking(parent_dir.mkdir, parents=True, exist_ok=True) except PermissionError: log.warning( "cannot_create_runtime_database_parent", diff --git a/backend/app/startup.py b/backend/app/startup.py index 9a38328..f07bc74 100644 --- a/backend/app/startup.py +++ b/backend/app/startup.py @@ -70,7 +70,7 @@ async def startup_shared_resources( A tuple of ``(http_session, scheduler)``. """ db_path: Path = Path(settings.database_path) - db_path.parent.mkdir(parents=True, exist_ok=True) + await run_blocking(db_path.parent.mkdir, parents=True, exist_ok=True) log.debug("database_directory_ensured", directory=str(db_path.parent))