MCPcopy Create free account
hub / github.com/Comfy-Org/ComfyUI / process_inputs

Function process_inputs

execution.py:254–306  ·  view source on GitHub ↗
(inputs, index=None, input_is_list=False)

Source from the content-addressed store, hash-verified

252
253 results = []
254 async def process_inputs(inputs, index=None, input_is_list=False):
255 if allow_interrupt:
256 nodes.before_node_execution()
257 execution_block = None
258 for k, v in inputs.items():
259 if input_is_list:
260 for e in v:
261 if isinstance(e, ExecutionBlocker):
262 v = e
263 break
264 if isinstance(v, ExecutionBlocker):
265 execution_block = execution_block_cb(v) if execution_block_cb else v
266 break
267 if execution_block is None:
268 if pre_execute_cb is not None and index is not None:
269 pre_execute_cb(index)
270 # V3
271 if isinstance(obj, _ComfyNodeInternal) or (is_class(obj) and issubclass(obj, _ComfyNodeInternal)):
272 # if is just a class, then assign no state, just create clone
273 if is_class(obj):
274 type_obj = obj
275 obj.VALIDATE_CLASS()
276 class_clone = obj.PREPARE_CLASS_CLONE(v3_data)
277 # otherwise, use class instance to populate/reuse some fields
278 else:
279 type_obj = type(obj)
280 type_obj.VALIDATE_CLASS()
281 class_clone = type_obj.PREPARE_CLASS_CLONE(v3_data)
282 f = make_locked_method_func(type_obj, func, class_clone)
283 # in case of dynamic inputs, restructure inputs to expected nested dict
284 if v3_data is not None:
285 inputs = _io.build_nested_inputs(inputs, v3_data)
286 # V1
287 else:
288 f = getattr(obj, func)
289 if inspect.iscoroutinefunction(f):
290 async def async_wrapper(f, prompt_id, unique_id, list_index, args):
291 with CurrentNodeContext(prompt_id, unique_id, list_index):
292 return await f(**args)
293 task = asyncio.create_task(async_wrapper(f, prompt_id, unique_id, index, args=inputs))
294 # Give the task a chance to execute without yielding
295 await asyncio.sleep(0)
296 if task.done():
297 result = task.result()
298 results.append(result)
299 else:
300 results.append(task)
301 else:
302 with CurrentNodeContext(prompt_id, unique_id, index):
303 result = f(**inputs)
304 results.append(result)
305 else:
306 results.append(execution_block)
307
308 if input_is_list:
309 await process_inputs(input_data_all, 0, input_is_list=input_is_list)

Callers 1

Calls 11

is_classFunction · 0.90
make_locked_method_funcFunction · 0.90
CurrentNodeContextClass · 0.90
execution_block_cbFunction · 0.85
pre_execute_cbFunction · 0.85
async_wrapperFunction · 0.85
VALIDATE_CLASSMethod · 0.80
PREPARE_CLASS_CLONEMethod · 0.80
sleepMethod · 0.80
resultMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected