Debug JSONL updates.
This commit is contained in:
@@ -87,6 +87,7 @@ async def start_background():
|
||||
global _background_task
|
||||
if _background_task is None:
|
||||
_background_task = asyncio.create_task(_background_loop())
|
||||
_logger.info("Database background task started")
|
||||
|
||||
|
||||
async def stop_background():
|
||||
|
||||
@@ -119,6 +119,9 @@ async def flush_changes(
|
||||
# Append all lines in a single write (binary mode for Windows compatibility)
|
||||
async with aiofiles.open(db_path, "ab") as f:
|
||||
await f.write(b"\n".join(lines) + b"\n")
|
||||
_logger.debug(
|
||||
"Flushed %d change(s) to %s", len(changes_to_write), db_path
|
||||
)
|
||||
return True
|
||||
except OSError:
|
||||
_logger.exception("Failed to flush database changes")
|
||||
|
||||
@@ -7,6 +7,7 @@ Write operations: Functions that validate and commit, or raise ValueError.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import secrets
|
||||
from collections import deque
|
||||
@@ -18,6 +19,8 @@ from uuid import UUID
|
||||
|
||||
import msgspec
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
from paskia.db.jsonl import (
|
||||
DB_PATH_DEFAULT,
|
||||
_ChangeRecord,
|
||||
@@ -98,6 +101,11 @@ class DB:
|
||||
create_change_record(self._current_actor, diff)
|
||||
)
|
||||
self._previous_builtins = current
|
||||
_logger.debug(
|
||||
"Queued change by %s, %d pending",
|
||||
self._current_actor,
|
||||
len(self._pending_changes),
|
||||
)
|
||||
|
||||
@contextmanager
|
||||
def transaction(self, actor: str = "system"):
|
||||
|
||||
Reference in New Issue
Block a user