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

Method acquire

asyncpg/pool.py:969–992  ·  view source on GitHub ↗

Acquire a database connection from the pool. :param float timeout: A timeout for acquiring a Connection. :return: An instance of :class:`~asyncpg.connection.Connection`. Can be used in an ``await`` expression or with an ``async with`` block. .. code-block:: python

(self, *, timeout=None)

Source from the content-addressed store, hash-verified

967 )
968
969 def acquire(self, *, timeout=None):
970 """Acquire a database connection from the pool.
971
972 :param float timeout: A timeout for acquiring a Connection.
973 :return: An instance of :class:`~asyncpg.connection.Connection`.
974
975 Can be used in an ``await`` expression or with an ``async with`` block.
976
977 .. code-block:: python
978
979 async with pool.acquire() as con:
980 await con.execute(...)
981
982 Or:
983
984 .. code-block:: python
985
986 con = await pool.acquire()
987 try:
988 await con.execute(...)
989 finally:
990 await pool.release(con)
991 """
992 return PoolAcquireContext(self, timeout)
993
994 async def _acquire(self, timeout):
995 async def _acquire_impl():

Callers 15

executeMethod · 0.95
executemanyMethod · 0.95
fetchMethod · 0.95
fetchvalMethod · 0.95
fetchrowMethod · 0.95
fetchmanyMethod · 0.95
copy_from_tableMethod · 0.95
copy_from_queryMethod · 0.95
copy_to_tableMethod · 0.95
copy_records_to_tableMethod · 0.95

Calls 1

PoolAcquireContextClass · 0.85

Tested by 15

test_listen_01Method · 0.36
test_listen_02Method · 0.36
workerMethod · 0.36
test_pool_03Method · 0.36
test_pool_04Method · 0.36
test_pool_06Method · 0.36
userMethod · 0.36