tzwm / comfyui-profiler

Calculate the execution time of all nodes.
134 stars 11 forks source link

Induces error "asyncio.locks.Lock object...is bound to a different event loop" #11

Open thefoxfarmer opened 2 months ago

thefoxfarmer commented 2 months ago

This happened immediately after installing the node. We're in here:

  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 27, in send_message
    await s.send_json('profiler', data)

Note that the Comfy-Dev-Utils package is installed and we're also inside that thing's profiler, it looks like. Perhaps they are incompatible?

0: 448x640 1 face, 3.4ms
0: 448x640 1 face, 3.4ms
Speed: 0.9ms preprocess, 3.4ms inference, 0.5ms postprocess per image at shape (1, 3, 448, 640)
Speed: 0.9ms preprocess, 3.4ms inference, 0.5ms postprocess per image at shape (1, 3, 448, 640)
Detailer: segment upscale for ((92.86456, 129.08794)) | crop region (278, 387) x 2.6464346796206093 -> (735, 1024)
Requested to load SDXL
Loading 1 new model
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:06<00:00,  7.16it/s]
#995 [FaceDetailer]: 7.52s
#987 [PreviewImage]: 0.01s
#988 [PreviewImage]: 0.01s
#957 [Image Batch]: 0.00s
#918 [PreviewImage]: 0.28s
Exception in thread Thread-4 (prompt_worker):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "ComfyUI/main.py", line 111, in prompt_worker
    e.execute(item[2], prompt_id, item[3], item[4])
  File "ComfyUI/custom_nodes/ComfyUI-0246/utils.py", line 381, in new_func
    res_value = old_func(*final_args, **kwargs)
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 93, in new_prompt_executor_execute
    ret = exist_PromptExecutor_execute(self, prompt, prompt_id, extra_data=extra_data, execute_outputs=execute_outputs)
  File "ComfyUI/custom_nodes/rgthree-comfy/__init__.py", line 211, in rgthree_execute
    return self.rgthree_old_execute(*args, **kwargs)
  File "ComfyUI/execution.py", line 391, in execute
    self.success, error, ex = recursive_execute(self.server, prompt, self.outputs, output_node_id, extra_data, executed, prompt_id, self.outputs_ui, self.object_storage)
  File "ComfyUI/custom_nodes/ComfyUI-Dev-Utils/nodes/execution_time.py", line 32, in swizzle_origin_recursive_execute
    result = origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 65, in new_recursive_execute
    ret = exist_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id, outputs_ui, object_storage)
  File "ComfyUI/execution.py", line 134, in recursive_execute
    result = recursive_execute(server, prompt, outputs, input_unique_id, extra_data, executed, prompt_id, outputs_ui, object_storage)
  File "ComfyUI/custom_nodes/ComfyUI-Dev-Utils/nodes/execution_time.py", line 32, in swizzle_origin_recursive_execute
    result = origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 73, in new_recursive_execute
    asyncio.run(send_message({
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 27, in send_message
    await s.send_json('profiler', data)
  File "ComfyUI/server.py", line 621, in send_json
    await send_socket_catch_exception(ws.send_json, message)
  File "ComfyUI/server.py", line 36, in send_socket_catch_exception
    await function(message)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/web_ws.py", line 351, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/web_ws.py", line 335, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/http_websocket.py", line 729, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/http_websocket.py", line 644, in _send_frame
    message = await compressobj.compress(message)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/compression_utils.py", line 71, in compress
    async with self._compress_lock:
  File "/usr/lib/python3.10/asyncio/locks.py", line 14, in __aenter__
    await self.acquire()
  File "/usr/lib/python3.10/asyncio/locks.py", line 106, in acquire
    fut = self._get_loop().create_future()
  File "/usr/lib/python3.10/asyncio/mixins.py", line 30, in _get_loop
    raise RuntimeError(f'{self!r} is bound to a different event loop')
RuntimeError: <asyncio.locks.Lock object at 0x7f110dce5f00 [locked]> is bound to a different event loop
smallersoup commented 1 month ago

This happened immediately after installing the node. We're in here:

  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 27, in send_message
    await s.send_json('profiler', data)

Note that the Comfy-Dev-Utils package is installed and we're also inside that thing's profiler, it looks like. Perhaps they are incompatible?

0: 448x640 1 face, 3.4ms
0: 448x640 1 face, 3.4ms
Speed: 0.9ms preprocess, 3.4ms inference, 0.5ms postprocess per image at shape (1, 3, 448, 640)
Speed: 0.9ms preprocess, 3.4ms inference, 0.5ms postprocess per image at shape (1, 3, 448, 640)
Detailer: segment upscale for ((92.86456, 129.08794)) | crop region (278, 387) x 2.6464346796206093 -> (735, 1024)
Requested to load SDXL
Loading 1 new model
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 50/50 [00:06<00:00,  7.16it/s]
#995 [FaceDetailer]: 7.52s
#987 [PreviewImage]: 0.01s
#988 [PreviewImage]: 0.01s
#957 [Image Batch]: 0.00s
#918 [PreviewImage]: 0.28s
Exception in thread Thread-4 (prompt_worker):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "ComfyUI/main.py", line 111, in prompt_worker
    e.execute(item[2], prompt_id, item[3], item[4])
  File "ComfyUI/custom_nodes/ComfyUI-0246/utils.py", line 381, in new_func
    res_value = old_func(*final_args, **kwargs)
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 93, in new_prompt_executor_execute
    ret = exist_PromptExecutor_execute(self, prompt, prompt_id, extra_data=extra_data, execute_outputs=execute_outputs)
  File "ComfyUI/custom_nodes/rgthree-comfy/__init__.py", line 211, in rgthree_execute
    return self.rgthree_old_execute(*args, **kwargs)
  File "ComfyUI/execution.py", line 391, in execute
    self.success, error, ex = recursive_execute(self.server, prompt, self.outputs, output_node_id, extra_data, executed, prompt_id, self.outputs_ui, self.object_storage)
  File "ComfyUI/custom_nodes/ComfyUI-Dev-Utils/nodes/execution_time.py", line 32, in swizzle_origin_recursive_execute
    result = origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 65, in new_recursive_execute
    ret = exist_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id, outputs_ui, object_storage)
  File "ComfyUI/execution.py", line 134, in recursive_execute
    result = recursive_execute(server, prompt, outputs, input_unique_id, extra_data, executed, prompt_id, outputs_ui, object_storage)
  File "ComfyUI/custom_nodes/ComfyUI-Dev-Utils/nodes/execution_time.py", line 32, in swizzle_origin_recursive_execute
    result = origin_recursive_execute(server, prompt, outputs, current_item, extra_data, executed, prompt_id,
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 73, in new_recursive_execute
    asyncio.run(send_message({
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "ComfyUI/custom_nodes/comfyui-profiler/__init__.py", line 27, in send_message
    await s.send_json('profiler', data)
  File "ComfyUI/server.py", line 621, in send_json
    await send_socket_catch_exception(ws.send_json, message)
  File "ComfyUI/server.py", line 36, in send_socket_catch_exception
    await function(message)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/web_ws.py", line 351, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/web_ws.py", line 335, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/http_websocket.py", line 729, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/http_websocket.py", line 644, in _send_frame
    message = await compressobj.compress(message)
  File "ComfyUI/venv/lib/python3.10/site-packages/aiohttp/compression_utils.py", line 71, in compress
    async with self._compress_lock:
  File "/usr/lib/python3.10/asyncio/locks.py", line 14, in __aenter__
    await self.acquire()
  File "/usr/lib/python3.10/asyncio/locks.py", line 106, in acquire
    fut = self._get_loop().create_future()
  File "/usr/lib/python3.10/asyncio/mixins.py", line 30, in _get_loop
    raise RuntimeError(f'{self!r} is bound to a different event loop')
RuntimeError: <asyncio.locks.Lock object at 0x7f110dce5f00 [locked]> is bound to a different event loop

Any luck fixing?I have the same error

smallersoup commented 1 month ago

BTW, I have not installed Comfy-Dev-Utils package