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

@@ -43,6 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed `WebsocketClientTransport` to use `FrameProcessorSetup.task_manager`
instead of `StartFrame.task_manager`.
### Performance
- Use `uvloop` as the new event loop on Linux and macOS systems.
## [0.0.68] - 2025-05-28
### Added

View File

@@ -31,7 +31,8 @@ dependencies = [
"pyloudnorm~=0.1.1",
"resampy~=0.4.3",
"soxr~=0.5.0",
"openai~=1.70.0"
"openai~=1.70.0",
"uvloop~=0.21.0; sys_platform!='win32'"
]
[project.urls]

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}) ᓚᘏᗢ")