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:
@@ -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
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
|
||||
// Bar chart with nodes icon
|
||||
const STATS_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="3" y="12" width="4" height="9" rx="1"/>
|
||||
<rect x="10" y="7" width="4" height="14" rx="1"/>
|
||||
<rect x="17" y="3" width="4" height="18" rx="1"/>
|
||||
<circle cx="5" cy="8" r="2" fill="currentColor" stroke="none"/>
|
||||
<circle cx="12" cy="3.5" r="2" fill="currentColor" stroke="none"/>
|
||||
<line x1="7" y1="8" x2="10" y2="4.5"/>
|
||||
</svg>`;
|
||||
|
||||
app.registerExtension({
|
||||
name: "comfyui.nodes_stats",
|
||||
|
||||
@@ -25,8 +35,11 @@ app.registerExtension({
|
||||
);
|
||||
|
||||
const btn = document.createElement("button");
|
||||
btn.textContent = "Node Stats";
|
||||
btn.innerHTML = STATS_ICON;
|
||||
btn.title = "Node Stats";
|
||||
btn.onclick = () => showStatsDialog();
|
||||
btn.style.cssText =
|
||||
"display:flex;align-items:center;justify-content:center;padding:6px;background:none;border:none;cursor:pointer;color:var(--input-text,#ddd);";
|
||||
|
||||
const menu = document.querySelector(".comfy-menu");
|
||||
if (menu) {
|
||||
|
||||
Reference in New Issue
Block a user