Comfy-Org / Comfy-Org/ComfyUI

asyncio.run() cannot be called from a running event loop

Open
#9,007 3 comments 2 reactions 0 assignees View on GitHub
bug-cop:user-resolved Potential Bug
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 6h
Merged PRs (30d)
155

Description

### Custom Node Testing

- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)

### Expected Behavior

run a async function

### Actual Behavior

RuntimeError: asyncio.run() cannot be called from a running event loop

### Steps to Reproduce

async def dosomething()
print("hello")
await asyncio.sleep(1)
print("world")

FUNCTION = "node_function"
def node_function(self, string,):
asyncio.run(dosomething())
return ("",)

### Debug Logs

```powershell
File "C:\Users\MyPC\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 191, in run
raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
```

### Other

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.