how to initialize db connection in prewarm
# ask-ai
s
how to initialize db connection in prewarm
t
Thanks for reaching out, Youssef. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The
prewarm()
method is used to initialize a database connection in the connection pool if no connections currently exist. It starts a background task that creates a new connection using
await self._connect()
and adds this connection to the available connections pool with
self._available.add(conn)
. This process does not block the main execution flow. Note that the method will not create a new connection if there are already existing connections or if a prewarming task is already running. Sources: livekit.agents.utils.connection_pool API documentation