fix: suppress WebSocket keepalive timeout tracebacks from stderr
This commit is contained in:
@@ -27,6 +27,19 @@ os.makedirs(BASE_DIR / "logs", exist_ok=True)
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
import asyncio
|
||||
import warnings
|
||||
from websockets.exceptions import ConnectionClosedError
|
||||
|
||||
def _handle_async_exception(loop, ctx):
|
||||
exc = ctx.get("exception")
|
||||
if isinstance(exc, ConnectionClosedError):
|
||||
return
|
||||
loop.default_exception_handler(ctx)
|
||||
|
||||
asyncio.get_event_loop().set_exception_handler(_handle_async_exception)
|
||||
warnings.filterwarnings("ignore", message=".*ping timeout.*")
|
||||
|
||||
logger.info("=" * 50)
|
||||
logger.info(" TurboSu - Racing Telemetry Dashboard")
|
||||
logger.info("=" * 50)
|
||||
|
||||
Reference in New Issue
Block a user