Support async for v3's execute function, still need to test validate_inputs, fingerprint_inputs, and check_lazy_status, fix Any type for v3 by introducing __ne__ trick from comfy_api's typing.py

This commit is contained in:
Jedrzej Kosinski
2025-07-18 15:50:42 -07:00
parent fd9c34a3eb
commit b6a4a4c664
4 changed files with 120 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ import logging # noqa
import folder_paths
import comfy.utils
import comfy.sd
import asyncio
@io.comfytype(io_type="XYZ")
@@ -203,8 +204,43 @@ class NInputsTest(io.ComfyNodeV3):
return io.NodeOutput(combined_image)
class V3TestSleep(io.ComfyNodeV3):
@classmethod
def define_schema(cls):
return io.SchemaV3(
node_id="V3_TestSleep",
display_name="V3 Test Sleep",
category="_for_testing",
description="Test async sleep functionality.",
inputs=[
io.AnyType.Input("value", display_name="Value"),
io.Float.Input("seconds", display_name="Seconds", default=1.0, min=0.0, max=9999.0, step=0.01, tooltip="The amount of seconds to sleep."),
],
outputs=[
io.AnyType.Output(),
],
hidden=[
io.Hidden.unique_id,
],
)
@classmethod
async def execute(cls, value: io.AnyType.Type, seconds: io.Float.Type, **kwargs):
logging.info(f"V3TestSleep: {cls.hidden.unique_id}")
pbar = comfy.utils.ProgressBar(seconds, node_id=cls.hidden.unique_id)
start = time.time()
expiration = start + seconds
now = start
while now < expiration:
now = time.time()
pbar.update_absolute(now - start)
await asyncio.sleep(0.02)
return io.NodeOutput(value)
NODES_LIST: list[type[io.ComfyNodeV3]] = [
V3TestNode,
V3LoraLoader,
NInputsTest,
V3TestSleep,
]