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

@@ -1,3 +1,4 @@
import asyncio
from dataclasses import asdict
from typing import Callable, Optional
@@ -118,9 +119,18 @@ def make_locked_method_func(type_obj, func, class_clone):
"""
Returns a function that, when called with **inputs, will execute:
getattr(type_obj, func).__func__(lock_class(class_clone), **inputs)
Supports both synchronous and asynchronous methods.
"""
locked_class = lock_class(class_clone)
method = getattr(type_obj, func).__func__
def wrapped_func(**inputs):
return method(locked_class, **inputs)
return wrapped_func
# Check if the original method is async
if asyncio.iscoroutinefunction(method):
async def wrapped_async_func(**inputs):
return await method(locked_class, **inputs)
return wrapped_async_func
else:
def wrapped_func(**inputs):
return method(locked_class, **inputs)
return wrapped_func