Move DB writes to background thread and add SVG icon

Record usage in a daemon thread to avoid blocking the event loop
with SQLite fsync on slow storage. Replace text button label with
a bar-chart-with-nodes SVG icon in the legacy menu fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 13:50:11 +01:00
parent 6d0e5d55ed
commit fcca25397c
2 changed files with 20 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import logging
import threading
from aiohttp import web
from server import PromptServer
@@ -25,7 +26,11 @@ def on_prompt_handler(json_data):
if ct:
class_types.add(ct)
if class_types:
tracker.record_usage(class_types, mapper)
threading.Thread(
target=tracker.record_usage,
args=(class_types, mapper),
daemon=True,
).start()
except Exception:
logger.warning("nodes-stats: error recording usage", exc_info=True)
return json_data