MCPcopy Create free account
hub / github.com/livekit/agents / test_get_expired

Function test_get_expired

tests/test_connection_pool.py:74–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72
73@pytest.mark.asyncio
74async def test_get_expired():
75 # Use a short max duration to simulate expiration.
76 dummy_connect = dummy_connect_factory()
77 pool = ConnectionPool(max_session_duration=1, connect_cb=dummy_connect)
78
79 conn = await pool.get(timeout=10.0)
80 pool.put(conn)
81 # Artificially set the connection's timestamp in the past to simulate expiration.
82 pool._connections[conn] = time.time() - 2 # 2 seconds ago (max_session_duration is 1)
83
84 conn2 = await pool.get(timeout=10.0)
85 assert conn2 is not conn, "Expected a new connection to be returned."

Callers

nothing calls this directly

Calls 5

getMethod · 0.95
putMethod · 0.95
ConnectionPoolClass · 0.90
dummy_connect_factoryFunction · 0.85
timeMethod · 0.45

Tested by

no test coverage detected