Skip to content

[Bug]: /sdapi/v1/txt2img endpoint not working #9046

Description

@Darklobi

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

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

  1. Start fast-stable-diffusion colab version by TheLastBen colab
  2. . Make a post request using to the endpoint /sdapi/v1/txt2img (or using any other tool like Postman)

1234

12345

What should have happened?

Generate image and return success response json body with image path

Commit where the problem happens

955df77

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

no

List of extensions

no

Console logs

API error: POST: https://41209b1e8d4c8c9c05.gradio.live/sdapi/v1/txt2img {'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     │ │
│ │                    0x7f45ac0faf70>                                       │ │
│ │                e = RuntimeError("There is no current event loop in       │ │
│ │                    thread 'AnyIO worker thread'.")                       │ │
│ │ handle_exception = <function api_middleware.<locals>.handle_exception at │ │
│ │                    0x7f45ac638dc0>                                       │ │
│ │          request = <starlette.requests.Request object at 0x7f45ac0b2790> │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /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 0x7f45ac06b0a0 [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        │ │
│ │        0x7f45adf50820>                                                   │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
RuntimeError: There is no current event loop in thread 'AnyIO worker thread'.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-reportReport of a bug, yet to be confirmed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions