Skip to content

Commit

Permalink
fix: uvloop
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfeil committed Nov 11, 2024
1 parent a13d2ab commit 0b7244f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libs/infinity_emb/infinity_emb/infinity_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,15 @@ def typer_option_resolve(*args):
CHECK_UVICORN.mark_required()
import typer
import uvicorn
import uvloop

try:
import uvloop

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
loopname = "uvloop"
except ImportError:
# Windows does not support uvloop
loopname = "auto"

tp = typer.Typer()

Expand Down Expand Up @@ -943,9 +951,9 @@ def v2(
api_key=api_key,
proxy_root_path=proxy_root_path,
)
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

uvicorn.run(
app, host=host, port=port, log_level=log_level.name, http="httptools", loop="uvloop"
app, host=host, port=port, log_level=log_level.name, http="httptools", loop=loopname
)

def cli():
Expand Down

0 comments on commit 0b7244f

Please sign in to comment.