zero01101/openOutpaint

[Bug]: RuntimeError: There is no current event loop in thread 'AnyIO worker thread'.

Closed this issue · 2 comments

What happened?

I clicked Dream and it didn't work.

The console returned this error:

API error: POST: https://info-kirk-singer-responsible.trycloudflare.com/sdapi/v1/img2img {'error': 'RuntimeError', 'detail': '', 'body': '', 'errors': "There is no current event loop in thread 'AnyIO worker thread'."}
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /usr/local/lib/python3.9/dist-packages/anyio/streams/memory.py:94 in receive │
│                                                                              │
│ /usr/local/lib/python3.9/dist-packages/anyio/streams/memory.py:89 in         │
│ receive_nowait                                                               │
╰──────────────────────────────────────────────────────────────────────────────╯
WouldBlock

During handling of the above exception, another exception occurred:

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /usr/local/lib/python3.9/dist-packages/starlette/middleware/base.py:43 in    │
│ call_next                                                                    │
│                                                                              │
│ /usr/local/lib/python3.9/dist-packages/anyio/streams/memory.py:114 in        │
│ receive                                                                      │
╰──────────────────────────────────────────────────────────────────────────────╯
EndOfStream

During handling of the above exception, another exception occurred:

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/api/api.py:145 in  │
│ exception_handling                                                           │
│                                                                              │
│   144 │   │   try:                                                           │
│ ❱ 145 │   │   │   return await call_next(request)                            │
│   146 │   │   except Exception as e:                                         │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │        call_next = <function                                             │ │
│ │                    BaseHTTPMiddleware.__call__.<locals>.call_next at     │ │
│ │                    0x7f8003301670>                                       │ │
│ │                e = RuntimeError("There is no current event loop in       │ │
│ │                    thread 'AnyIO worker thread'.")                       │ │
│ │ handle_exception = <function api_middleware.<locals>.handle_exception at │ │
│ │                    0x7f8003071ca0>                                       │ │
│ │          request = <starlette.requests.Request object at 0x7f8207912940> │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/local/lib/python3.9/dist-packages/starlette/middleware/base.py:46 in    │
│ call_next                                                                    │
│                                                                              │
│                           ... 25 frames hidden ...                           │
│                                                                              │
│ /usr/lib/python3.9/asyncio/locks.py:81 in __init__                           │
│                                                                              │
│    80 │   │   if loop is None:                                               │
│ ❱  81 │   │   │   self._loop = events.get_event_loop()                       │
│    82 │   │   else:                                                          │
│                                                                              │
│ ╭──────────────────────────── locals ─────────────────────────────╮          │
│ │ loop = None                                                     │          │
│ │ self = <asyncio.locks.Lock object at 0x7f8207369f40 [unlocked]> │          │
│ ╰─────────────────────────────────────────────────────────────────╯          │
│                                                                              │
│ /usr/lib/python3.9/asyncio/events.py:642 in get_event_loop                   │
│                                                                              │
│   641 │   │   if self._local._loop is None:                                  │
│ ❱ 642 │   │   │   raise RuntimeError('There is no current event loop in thre │
│   643 │   │   │   │   │   │   │      % threading.current_thread().name)      │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │ self = <asyncio.unix_events._UnixDefaultEventLoopPolicy object at        │ │
│ │        0x7f8207cdc8e0>                                                   │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: There is no current event loop in thread 'AnyIO worker thread'.

Steps to reproduce the problem

  1. Run A1111 WebUI on TheLastBen's fast_stable_diffusion colab notebook with OpenOutpaint installed.
  2. Go to OpenOutpaint tab
  3. Click dream

What should have happened?

Dream should have generated an image.

Commit where the problem happens

5fb01c9

What platforms do you use to access openOutpaint?

Other/Cloud

What browsers do you use to access the UI ?

Google Chrome

Browser Extensions/Addons

YouTube Playlist Duration
Save To Google Drive
Download Plus

AUTOMATIC1111 webUI Commandline Arguments

--share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt "$model" --xformers $auth --disable-console-progressbars

Additional information

No response

seems to be equivalent to zero01101/openOutpaint-webUI-extension#46 but i'll leave this issue here in case people check this repo instead

have you seen this issue? could you try going to http://127.0.0.1:7860/docs#/default/text2imgapi_sdapi_v1_txt2img_post, click try it out and populate the request body input with

{
	"batch_size": 1,
	"cfg_scale": 7,
	"enable_hr": false,
	"height": 512,
	"n_iter": 1,
	"negative_prompt": "test",
	"prompt": "test",
	"restore_faces": false,
	"sampler_index": "DDIM",
	"seed": "1",
	"steps": 1,
	"width": 512
}

and execute it? it should return a base64 string if webUI's API is returning images successfully

yeah, this is almost certainly going to be in webUI given the consistency of the issue and how it seems to be presenting itself, plus AUTOMATIC1111/stable-diffusion-webui#9046 and AUTOMATIC1111/stable-diffusion-webui#9319 are kind of a giveaway... closing for now, but if it continues to happen after 9319 (or similar) is merged, then feel free to reopen