use uvloop as the new event loop on Linux and macOS

This commit is contained in:
Aleix Conchillo Flaqué
2025-05-28 19:23:50 -07:00
parent 2395ca0057
commit fb66df2efd
3 changed files with 23 additions and 2 deletions

View File

@@ -4,10 +4,26 @@
# SPDX-License-Identifier: BSD 2-Clause License
#
import asyncio
import sys
from importlib.metadata import version
from loguru import logger
__version__ = version("pipecat-ai")
logger.info(f"ᓚᘏᗢ Pipecat {__version__} ᓚᘏᗢ")
event_loop = "asyncio"
if sys.platform in ("linux", "darwin"):
try:
import asyncio
import uvloop
event_loop = f"uvloop {uvloop.__version__}"
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except ImportError:
logger.debug(f"Couldn't find `uvloop`")
pass
logger.info(f"ᓚᘏᗢ Pipecat {__version__} ({event_loop}; Python {sys.version}) ᓚᘏᗢ")