This commit is contained in:
2026-01-16 03:25:36 -08:00
parent 6bc3cbfe9c
commit 00bee0011c
3 changed files with 42 additions and 15 deletions

View File

@@ -16,6 +16,7 @@ import logging
import subprocess
import shutil
import time
import os
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path, PurePosixPath
@@ -23,12 +24,18 @@ from threading import RLock
from typing import Optional, Dict, Any, List, Tuple, Set
from SYS.utils import sha256_file, expand_path
from SYS.logger import debug as mm_debug
from SYS.logger import debug as _debug
logger = logging.getLogger(__name__)
WORKER_LOG_MAX_ENTRIES = 50 # Reduced from 99 to keep log size down
MAX_FINISHED_WORKERS = 100 # Only keep 100 finished workers globally
# Wrapper: only emit folder DB diagnostics when MM_DEBUG=1
def mm_debug(*args, **kwargs):
if not os.environ.get("MM_DEBUG"):
return
_debug(*args, **kwargs)
# Helper: decorate DB write methods to retry transient SQLITE 'database is locked' errors
def _db_retry(max_attempts: int = 6, base_sleep: float = 0.1):
def _decorator(func):