Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
d4273ead
Commit
d4273ead
authored
Apr 02, 2023
by
comfyanonymous
Browse files
Merge branch 'queue-queue' of
https://github.com/pythongosssss/ComfyUI
parents
6be7c642
178fc763
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
19 deletions
+44
-19
web/scripts/app.js
web/scripts/app.js
+44
-19
No files found.
web/scripts/app.js
View file @
d4273ead
...
@@ -5,6 +5,15 @@ import { defaultGraph } from "./defaultGraph.js";
...
@@ -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,31 +924,47 @@ class ComfyApp {
...
@@ -915,31 +924,47 @@ class ComfyApp {
}
}
async
queuePrompt
(
number
,
batchCount
=
1
)
{
async
queuePrompt
(
number
,
batchCount
=
1
)
{
for
(
let
i
=
0
;
i
<
batchCount
;
i
++
)
{
this
.
#
queueItems
.
push
({
number
,
batchCount
});
const
p
=
await
this
.
graphToPrompt
();
try
{
// Only have one action process the items so each one gets a unique seed correctly
await
api
.
queuePrompt
(
number
,
p
);
if
(
this
.
#
processingQueue
)
{
}
catch
(
error
)
{
return
;
this
.
ui
.
dialog
.
show
(
error
.
response
||
error
.
toString
());
}
return
;
}
this
.
#
processingQueue
=
true
;
try
{
while
(
this
.
#
queueItems
.
length
)
{
({
number
,
batchCount
}
=
this
.
#
queueItems
.
pop
());
for
(
const
n
of
p
.
workflow
.
nodes
)
{
for
(
let
i
=
0
;
i
<
batchCount
;
i
++
)
{
const
node
=
graph
.
getNodeById
(
n
.
id
);
const
p
=
await
this
.
graphToPrompt
();
if
(
node
.
widgets
)
{
for
(
const
widget
of
node
.
widgets
)
{
try
{
// Allow widgets to run callbacks after a prompt has been queued
await
api
.
queuePrompt
(
number
,
p
);
// e.g. random seed after every gen
}
catch
(
error
)
{
if
(
widget
.
afterQueued
)
{
this
.
ui
.
dialog
.
show
(
error
.
response
||
error
.
toString
());
widget
.
afterQueued
();
break
;
}
for
(
const
n
of
p
.
workflow
.
nodes
)
{
const
node
=
graph
.
getNodeById
(
n
.
id
);
if
(
node
.
widgets
)
{
for
(
const
widget
of
node
.
widgets
)
{
// Allow widgets to run callbacks after a prompt has been queued
// e.g. random seed after every gen
if
(
widget
.
afterQueued
)
{
widget
.
afterQueued
();
}
}
}
}
}
}
this
.
canvas
.
draw
(
true
,
true
);
await
this
.
ui
.
queue
.
update
();
}
}
}
}
}
finally
{
this
.
canvas
.
draw
(
true
,
true
);
this
.
#
processingQueue
=
false
;
await
this
.
ui
.
queue
.
update
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment