From 03938223d84eb85bdc22ddfd8761f14638263d25 Mon Sep 17 00:00:00 2001 From: Aleksandr Vishniakov Date: Thu, 23 Jan 2025 00:23:39 +0200 Subject: [PATCH 1/2] fix: replace asyncio default event loop with uvloop --- backend/chainlit/cli/__init__.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/backend/chainlit/cli/__init__.py b/backend/chainlit/cli/__init__.py index f4671221ce..202062ddb2 100644 --- a/backend/chainlit/cli/__init__.py +++ b/backend/chainlit/cli/__init__.py @@ -89,23 +89,18 @@ def run_chainlit(target: str): log_level = "debug" if config.run.debug else "error" # Start the server - async def start(): - config = uvicorn.Config( - app, - host=host, - port=port, - ws=ws_protocol, - log_level=log_level, - ws_per_message_deflate=ws_per_message_deflate, - ssl_keyfile=ssl_keyfile, - ssl_certfile=ssl_certfile, - ) - server = uvicorn.Server(config) - await server.serve() - - # Run the asyncio event loop instead of uvloop to enable re entrance - asyncio.run(start()) - # uvicorn.run(app, host=host, port=port, log_level=log_level) + uvicorn_config = uvicorn.Config( + app, + host=host, + port=port, + ws=ws_protocol, + log_level=log_level, + ws_per_message_deflate=ws_per_message_deflate, + ssl_keyfile=ssl_keyfile, + ssl_certfile=ssl_certfile, + ) + server = uvicorn.Server(uvicorn_config) + server.run() # Define the "run" command for Chainlit CLI From 0f5a5e20f126156e9609e89bd3a89b53b7f365d3 Mon Sep 17 00:00:00 2001 From: Aleksandr Vishniakov Date: Thu, 23 Jan 2025 00:44:30 +0200 Subject: [PATCH 2/2] lint: fix linting --- backend/chainlit/cli/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/chainlit/cli/__init__.py b/backend/chainlit/cli/__init__.py index 2c221a7778..23d11065da 100644 --- a/backend/chainlit/cli/__init__.py +++ b/backend/chainlit/cli/__init__.py @@ -1,4 +1,3 @@ -import asyncio import os import click