MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / connect

Method connect

asyncpg/pool.py:165–184  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

163 return not self._in_use
164
165 async def connect(self) -> None:
166 if self._con is not None:
167 raise exceptions.InternalClientError(
168 'PoolConnectionHolder.connect() called while another '
169 'connection already exists')
170
171 generation = self._pool._generation
172 con = await self._pool._get_new_connection()
173 if self._pool.is_closing():
174 await con.close()
175 raise exceptions.InterfaceError('pool is closing')
176 if con.is_closed():
177 raise exceptions.ConnectionDoesNotExistError(
178 'connection was closed during pool initialization')
179 self._con = con
180 # Notify live holders without keeping an abandoned pool alive.
181 con._pool_holder = weakref.ref(self)
182 self._generation = generation
183 self._maybe_cancel_inactive_callback()
184 self._setup_inactive_callback()
185
186 async def acquire(self) -> PoolConnectionProxy:
187 if self._con is None or self._con.is_closed():

Callers 3

acquireMethod · 0.95
_initializeMethod · 0.95
_maintain_min_sizeMethod · 0.45

Calls 6

_get_new_connectionMethod · 0.80
is_closingMethod · 0.80
is_closedMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected