Skip to content

Commit

Permalink
Ignore websockets deprecation warnings when starting uvicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
bunchesofdonald committed Feb 26, 2025
1 parent 883471e commit 3c3cde1
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/prefect/cli/cloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import traceback
import uuid
import urllib.parse
import warnings
import webbrowser
from contextlib import asynccontextmanager
from typing import (
Expand Down Expand Up @@ -131,7 +132,18 @@ async def serve_login_api(
try:
# Yield the server object
task_status.started(server)
await server.serve()
with warnings.catch_warnings():
# Uvicorn uses the deprecated pieces of websockets, filter out
# the warnings until uvicorn has its dependencies updated
warnings.filterwarnings(
"ignore", category=DeprecationWarning, module="websockets"
)
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
module="uvicorn.protocols.websockets",
)
await server.serve()
except anyio.get_cancelled_exc_class():
pass # Already cancelled, do not cancel again
except SystemExit as exc:
Expand Down

0 comments on commit 3c3cde1

Please sign in to comment.