Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion tests/test_plugin_google_realtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from contextlib import asynccontextmanager

import pytest
from google.genai import types
from google.genai import _api_client, client as genai_client, types

from livekit.agents import llm, utils
from livekit.plugins.google.realtime.api_proto import ClientEvents
Expand All @@ -14,6 +14,20 @@

pytestmark = pytest.mark.unit


# The genai ``AsyncClient.__del__`` and ``BaseApiClient.__del__`` schedule
# ``aclose()`` on whatever event loop is running when the garbage collector
# reaches them. Sessions in this module close their clients explicitly in
# ``RealtimeSession.aclose()``, so those finalizers are pure redundancy — but
# they leak tasks into whichever test happens to be running at GC time (issue
# #6881). Disarm them here, in the module that owns the clients.
def _noop_finalizer(self: object) -> None:
pass


genai_client.AsyncClient.__del__ = _noop_finalizer # type: ignore[attr-defined]
_api_client.BaseApiClient.__del__ = _noop_finalizer # type: ignore[attr-defined]

# 10ms of silence at the output sample rate (24kHz mono, 16-bit)
_PCM_FRAME = b"\x00\x01" * 240

Expand Down