add custom asyncio.wait_for()

This patch uses `wait_for2` package to implement `asyncio.wait_for()` for
Python < 3.12.

In Python 3.12, `asyncio.wait_for()` is implemented in terms of
`asyncio.timeout()` which fixed a bunch of issues. However, this was never
backported (because of the lack of `async.timeout()`) and there are still many
remainig issues, specially in Python 3.10, in `async.wait_for()`.

See https://github.com/python/cpython/pull/98518
This commit is contained in:
Aleix Conchillo Flaqué
2025-08-20 10:58:09 -07:00
parent 5286591826
commit f387776985
31 changed files with 119 additions and 53 deletions

View File

@@ -43,6 +43,7 @@ from pipecat.services.deepgram.stt import DeepgramSTTService
from pipecat.services.llm_service import FunctionCallParams
from pipecat.services.openai.llm import OpenAILLMService
from pipecat.transports.services.daily import DailyParams, DailyTransport
from pipecat.utils.asyncio.timeout import wait_for
SCRIPT_DIR = Path(__file__).resolve().parent
@@ -122,7 +123,7 @@ class EvalRunner:
logger.error(f"ERROR: Unable to run {example_file}: {e}")
try:
result = await asyncio.wait_for(self._queue.get(), timeout=1.0)
result = await wait_for(self._queue.get(), timeout=1.0)
except asyncio.TimeoutError:
result = False