Added a queue for the queue action
This commit is contained in:
parent
0d972b85e6
commit
178fc76363
@ -5,6 +5,15 @@ import { defaultGraph } from "./defaultGraph.js";
|
|||||||
import { getPngMetadata, importA1111 } from "./pnginfo.js";
|
import { getPngMetadata, importA1111 } from "./pnginfo.js";
|
||||||
|
|
||||||
class ComfyApp {
|
class ComfyApp {
|
||||||
|
/**
|
||||||
|
* List of {number, batchCount} entries to queue
|
||||||
|
*/
|
||||||
|
#queueItems = [];
|
||||||
|
/**
|
||||||
|
* If the queue is currently being processed
|
||||||
|
*/
|
||||||
|
#processingQueue = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.ui = new ComfyUI(this);
|
this.ui = new ComfyUI(this);
|
||||||
this.extensions = [];
|
this.extensions = [];
|
||||||
@ -915,6 +924,18 @@ class ComfyApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async queuePrompt(number, batchCount = 1) {
|
async queuePrompt(number, batchCount = 1) {
|
||||||
|
this.#queueItems.push({ number, batchCount });
|
||||||
|
|
||||||
|
// Only have one action process the items so each one gets a unique seed correctly
|
||||||
|
if (this.#processingQueue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.#processingQueue = true;
|
||||||
|
try {
|
||||||
|
while (this.#queueItems.length) {
|
||||||
|
({ number, batchCount } = this.#queueItems.pop());
|
||||||
|
|
||||||
for (let i = 0; i < batchCount; i++) {
|
for (let i = 0; i < batchCount; i++) {
|
||||||
const p = await this.graphToPrompt();
|
const p = await this.graphToPrompt();
|
||||||
|
|
||||||
@ -922,7 +943,7 @@ class ComfyApp {
|
|||||||
await api.queuePrompt(number, p);
|
await api.queuePrompt(number, p);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.ui.dialog.show(error.response || error.toString());
|
this.ui.dialog.show(error.response || error.toString());
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const n of p.workflow.nodes) {
|
for (const n of p.workflow.nodes) {
|
||||||
@ -942,6 +963,10 @@ class ComfyApp {
|
|||||||
await this.ui.queue.update();
|
await this.ui.queue.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.#processingQueue = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads workflow data from the specified file
|
* Loads workflow data from the specified file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user