Closed Darklobi closed 1 year ago
same here, must be a new thing
Can confirm, just updated my webui installation and it broke the API I guess I have to downgrade then...
Same
same
I also encountered the same problem.
Same error on Colab. On local Windows PC - OK (just done fresh install).
yep. same issue in colab
If this problem is on colab, it's a Linux problem I believe since I try to make the API work on my server. Isn't there any solution?
Could anyone solve this?
any solution for colab?
i didnt find anything yet
sry wrong button
Same here. I'm using 'git checkout 9377092a892687a8ae43ba5f7df44f0929ab2997' as a temporary solution
I have the same problem
Another workaround while keeping the latest commit is to edit the modules/api/api.py
.
I don't think this is a good solution though, so I don't want to make a PR.
diff --git a/modules/api/api.py b/modules/api/api.py
index 518b2a61..a9cef928 100644
--- a/modules/api/api.py
+++ b/modules/api/api.py
@@ -29,6 +29,7 @@ from modules import devices
from typing import List
import piexif
import piexif.helper
+import asyncio
def upscaler_to_index(name: str):
try:
@@ -276,6 +277,15 @@ class Api:
return script_args
def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):
+ try:
+ loop = asyncio.get_event_loop()
+ except RuntimeError as e:
+ if str(e).startswith('There is no current event loop in thread'):
+ loop = asyncio.new_event_loop()
+ asyncio.set_event_loop(loop)
+ else:
+ raise
+
script_runner = scripts.scripts_txt2img
if not script_runner.scripts:
script_runner.initialize_scripts(False)
same
@MeemeeLab solution worked... thanks for this.
until some1 fix this issue, @MeemeeLab solution is working fine, thanks for the help.
The issue is in the source code.
def get_event_loop(self):
"""Get the event loop.
This may be None or an instance of EventLoop.
"""
if (self._local._loop is None and
not self._local._set_called and
isinstance(threading.current_thread(), threading._MainThread)):
self.set_event_loop(self.new_event_loop())
if self._local._loop is None:
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
return self._local._loop
The issue is in the source code.
def get_event_loop(self): """Get the event loop. This may be None or an instance of EventLoop. """ if (self._local._loop is None and not self._local._set_called and isinstance(threading.current_thread(), threading._MainThread)): self.set_event_loop(self.new_event_loop()) if self._local._loop is None: raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) return self._local._loop
I belive it's internal code of asyncio, there's should be a mistake in the code, not in the library.
Is there any solution to fix the error on colab?
Is there any solution to fix the error?
Experiencing this issue on img2img generation as well txt2img. @MeemeeLab worked but needed to add that code snippet into both functions.
Same
It's been quite long since this problem has been persisting in the /sdapi/v1/txt2img
May I ask you to solve this problem yet? I'm also having this troublesome problem now
Its back to normal thanks.
Is there an existing issue for this?
What happened?
Today when i tried to use my discord bot to make some requests to the endpoint /sdapi/v1/txt2img, i kept getting the error: "There is no current event loop in thread 'AnyIO worker thread'." Last successful generations were around 48h ago.
Steps to reproduce the problem
What should have happened?
Generate image and return success response json body with image path
Commit where the problem happens
https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/955df7751eef11bb7697e2d77f6b8a6226b21e13
What platforms do you use to access the UI ?
Other/Cloud
What browsers do you use to access the UI ?
Google Chrome
Command Line Arguments
List of extensions
no
Console logs
Additional information
No response