Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
86bafb62
Commit
86bafb62
authored
Apr 29, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put asyncio fix into a function to make it more obvious where it starts and ends
parent
24dec9c8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
33 deletions
+34
-33
webui.py
webui.py
+34
-33
No files found.
webui.py
View file @
86bafb62
...
...
@@ -5,7 +5,6 @@ import importlib
import
signal
import
re
import
warnings
import
asyncio
from
fastapi
import
FastAPI
from
fastapi.middleware.cors
import
CORSMiddleware
from
fastapi.middleware.gzip
import
GZipMiddleware
...
...
@@ -67,30 +66,31 @@ if cmd_opts.server_name:
else
:
server_name
=
"0.0.0.0"
if
cmd_opts
.
listen
else
None
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.
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).
"""
Usage::
import
asyncio
asyncio.set_event_loop_policy(AnyThreadEventLoopPolicy())
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
.. versionadded:: 5.0
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
:
...
...
@@ -104,8 +104,7 @@ class AnyThreadEventLoopPolicy(_BasePolicy): # type: ignore
self
.
set_event_loop
(
loop
)
return
loop
asyncio
.
set_event_loop_policy
(
AnyThreadEventLoopPolicy
())
asyncio
.
set_event_loop_policy
(
AnyThreadEventLoopPolicy
())
def
check_versions
():
...
...
@@ -140,6 +139,8 @@ Use --skip-version-check commandline argument to disable this check.
def
initialize
():
fix_asyncio_event_loop_policy
()
check_versions
()
extensions
.
list_extensions
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment