diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-04-29 08:58:54 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 08:58:54 +0000 |
commit | f54cd3f1586ec8d20ffcaff184ba2e680bb8cb8b (patch) | |
tree | 7af57d3994e5db508c89f43858a67aefd917450b /webui.py | |
parent | 7fb72edaffd3d4f2336d2478a424fc455f2376a6 (diff) | |
parent | e55cb92067094564c259b515b8a6ec3869654083 (diff) | |
download | stable-diffusion-webui-gfx803-f54cd3f1586ec8d20ffcaff184ba2e680bb8cb8b.tar.gz stable-diffusion-webui-gfx803-f54cd3f1586ec8d20ffcaff184ba2e680bb8cb8b.tar.bz2 stable-diffusion-webui-gfx803-f54cd3f1586ec8d20ffcaff184ba2e680bb8cb8b.zip |
Merge branch 'dev' into torch
Diffstat (limited to 'webui.py')
-rw-r--r-- | webui.py | 45 |
1 files changed, 42 insertions, 3 deletions
@@ -69,6 +69,46 @@ else: server_name = "0.0.0.0" if cmd_opts.listen else None
+def fix_asyncio_event_loop_policy():
+ """
+ The default `asyncio` event loop policy only automatically creates
+ event loops in the main threads. Other threads must create event
+ loops explicitly or `asyncio.get_event_loop` (and therefore
+ `.IOLoop.current`) will fail. Installing this policy allows event
+ loops to be created automatically on any thread, matching the
+ behavior of Tornado versions prior to 5.0 (or 5.0 on Python 2).
+ """
+
+ import asyncio
+
+ if sys.platform == "win32" and hasattr(asyncio, "WindowsSelectorEventLoopPolicy"):
+ # "Any thread" and "selector" should be orthogonal, but there's not a clean
+ # interface for composing policies so pick the right base.
+ _BasePolicy = asyncio.WindowsSelectorEventLoopPolicy # type: ignore
+ else:
+ _BasePolicy = asyncio.DefaultEventLoopPolicy
+
+ class AnyThreadEventLoopPolicy(_BasePolicy): # type: ignore
+ """Event loop policy that allows loop creation on any thread.
+ Usage::
+
+ asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
+ """
+
+ def get_event_loop(self) -> asyncio.AbstractEventLoop:
+ try:
+ return super().get_event_loop()
+ except (RuntimeError, AssertionError):
+ # This was an AssertionError in python 3.4.2 (which ships with debian jessie)
+ # and changed to a RuntimeError in 3.4.3.
+ # "There is no current event loop in thread %r"
+ loop = self.new_event_loop()
+ self.set_event_loop(loop)
+ return loop
+
+ asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
+
+
def check_versions():
if shared.cmd_opts.skip_version_check:
return
@@ -101,6 +141,8 @@ Use --skip-version-check commandline argument to disable this check. def initialize():
+ fix_asyncio_event_loop_policy()
+
check_versions()
extensions.list_extensions()
@@ -128,9 +170,6 @@ def initialize(): modules.scripts.load_scripts()
startup_timer.record("load scripts")
- modelloader.load_upscalers()
- startup_timer.record("load upscalers")
-
modules.sd_vae.refresh_vae_list()
startup_timer.record("refresh VAE")
|