crystian / ComfyUI-Crystools

A powerful set of tools for ComfyUI
MIT License
671 stars 31 forks source link

Event loop error in asyncio Lock #7

Closed dcondic closed 7 months ago

dcondic commented 7 months ago

Describe the bug After update 1/8/2024 3:44AM it worked for a while but now gives error every time asyncio.locks.lock object at 0x00000217c74b1360 [unlocked, waiters:1]> is bound to a different event loop

To Reproduce occurs in all workflow

Expected behavior when disabled "ComfyUI-Crystools.disable" everything works again

Screenshots image

Version: Loading: ComfyUI-Manager (V1.25.2) ComfyUI Revision: 1886 [6a10640f] | Released on '2024-01-08'

Additional context Total VRAM 8191 MB, total RAM 16302 MB xformers version: 0.0.23.post1+cu118 Set vram state to: NORMAL_VRAM Device: cuda:0 NVIDIA GeForce RTX 3070 : cudaMallocAsync VAE dtype: torch.bfloat16 Torch version: 2.1.2+cu118

crystian commented 7 months ago

@dcondic ok, I will check, but for now, can you try to disable the monitors on settings? I like to know if it is working thanks!

crystian commented 7 months ago

btw, which version of python do you have?

dcondic commented 7 months ago

crystian thanks for answer

With monitors enabled same error happend image image

as you suggested: With monitors disabled everything works fine image

Python ver. image

ada-lovecraft commented 7 months ago

Adding to this:

Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "D:\dev-tools\stable-diffusion\Comfy-UI\main.py", line 241, in <module>
    loop.run_until_complete(run(server, address=args.listen, port=args.port, verbose=not args.dont_print_server, call_on_start=call_on_start))
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\asyncio\base_events.py", line 650, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "D:\dev-tools\stable-diffusion\Comfy-UI\main.py", line 143, in run
    await asyncio.gather(server.start(address, port, verbose, call_on_start), server.publish_loop())
  File "D:\dev-tools\stable-diffusion\Comfy-UI\server.py", line 624, in publish_loop
    await self.send(*msg)
  File "D:\dev-tools\stable-diffusion\Comfy-UI\server.py", line 559, in send
    await self.send_json(event, data, sid)
  File "D:\dev-tools\stable-diffusion\Comfy-UI\server.py", line 612, in send_json
    await send_socket_catch_exception(self.sockets[sid].send_json, message)
  File "D:\dev-tools\stable-diffusion\Comfy-UI\server.py", line 40, in send_socket_catch_exception
    await function(message)
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\site-packages\aiohttp\web_ws.py", line 352, in send_json
    await self.send_str(dumps(data), compress=compress)
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\site-packages\aiohttp\web_ws.py", line 336, in send_str
    await self._writer.send(data, binary=False, compress=compress)
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\site-packages\aiohttp\http_websocket.py", line 729, in send
    await self._send_frame(message, WSMsgType.TEXT, compress)
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\site-packages\aiohttp\http_websocket.py", line 644, in _send_frame
    message = await compressobj.compress(message)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\site-packages\aiohttp\compression_utils.py", line 71, in compress
    async with self._compress_lock:
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\asyncio\locks.py", line 15, in __aenter__
    await self.acquire()
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\asyncio\locks.py", line 106, in acquire
    fut = self._get_loop().create_future()
          ^^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\envs\comfy\Lib\asyncio\mixins.py", line 20, in _get_loop
    raise RuntimeError(f'{self!r} is bound to a different event loop')
RuntimeError: <asyncio.locks.Lock object at 0x00000160D0C32550 [unlocked, waiters:1]> is bound to a different event loop

workflow (1)

Python 3.11

I hope we can get this fixed because this immediately became an essential tool for me. I use ComfyUI remotely from the install and being able to see the resource usage is super helpful.

crystian commented 7 months ago

Remotely? Can you explain it to me, please? Because I think the reason can come from there Thanks!

crystian commented 7 months ago

I didn't test with colab or others ¯_(ツ)_/¯

ada-lovecraft commented 7 months ago

It's running on my pc on my local network. Happens when I sit at the computer and use the same workflow, lol. It's not running in a cloud environment or anything.

crystian commented 7 months ago

@ada-lovecraft Oh, ok hehe, I'll check right now, meantime you can deactivate the monitors from the settings

crystian commented 7 months ago

btw, I tried it on colab and works! :)

crystian commented 7 months ago

can you help me with this?

https://www.reddit.com/r/comfyui/comments/19190qe/comment/kgzv2nx/?utm_source=reddit&utm_medium=web2x&context=3

crystian commented 7 months ago

Could you test it? @ada-lovecraft @dcondic on dev

LuckyFan commented 7 months ago

Hi @crystian I tested your dev branch, it still happens, but not causing Comfyui to quit anymore like before

image

But the gadgets stopped working

image
crystian commented 7 months ago

@LuckyFan thanks! I release that and still working on it

crystian commented 7 months ago

I tried different scenarios, and I can't reproduce it :(

May you reinstall all dependencies again (removing venv folder)

You can use something like my gist to install ComfyUI with some extensions in less than 10 minutes

crystian commented 7 months ago

the same for you @dcondic and @ada-lovecraft , thanks

snottyone commented 7 months ago

i got the same error, comfyui dies in the background first sign is that the graphs stop working (except the progress bar) or comfyui just crashes without that happening first happens so often (as in: every ~5th runs) that i removed the whole package for now

edit to add: whole SD installation is a few days old, so no ancient python etc

crystian commented 7 months ago

I need more info @snottyone please, copy, paste and refill:


Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Please attach a workflow file to make it easier for others to reproduce the error!

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Error in console:
If applicable, add the error message from the console.

Versions:
Copy the output of the console (4 parts), like this:

** Python version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Total VRAM 12287 MB, total RAM 130996 MB
Set vram state to: NORMAL_VRAM
### Loading: ComfyUI-Manager (V1.25.3)
### ComfyUI Revision: 1886 [6a10640f] | Released on '2024-01-08'
[Crystools INFO] Crystools version: 1.4.0
[Crystools INFO] CPU: AMD Ryzen 9 5950X 16-Core Processor - Arch: AMD64 - OS: Windows 10
[Crystools INFO] NVIDIA Driver detected - 546.33 - cuda:0 NVIDIA GeForce RTX 3080 Ti : cudaMallocAsync

Additional context
Add any other context about the problem here.

crystian commented 7 months ago

I made a change, it (may) will fix this issue, it is on dev; if you want to try it, you need to do:

cd custom_nodes\ComfyUI-Crystools
git checkout -b dev origin/dev
snottyone commented 7 months ago

I made a change, it (may) will fix this issue, it is on dev; if you want to try it, you need to do:

for me, fixed it, thank you very much :)

crystian commented 7 months ago

just for the check, on dev? @snottyone

ada-lovecraft commented 7 months ago

@crystian I'll install the latest dev version and give it a try.

snottyone commented 7 months ago

just for the check, on dev? @snottyone

yes, followed your instructions, dev works like charm

crystian commented 7 months ago

Merge! You can install it normally; thanks for your help! @snottyone