MCPcopy
hub / github.com/MagicStack/asyncpg / acquire

Method acquire

asyncpg/pool.py:852–875  ·  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

850 )
851
852 def acquire(self, *, timeout=None):
853 """Acquire a database connection from the pool.
854
855 :param float timeout: A timeout for acquiring a Connection.
856 :return: An instance of :class:`~asyncpg.connection.Connection`.
857
858 Can be used in an ``await`` expression or with an ``async with`` block.
859
860 .. code-block:: python
861
862 async with pool.acquire() as con:
863 await con.execute(...)
864
865 Or:
866
867 .. code-block:: python
868
869 con = await pool.acquire()
870 try:
871 await con.execute(...)
872 finally:
873 await pool.release(con)
874 """
875 return PoolAcquireContext(self, timeout)
876
877 async def _acquire(self, timeout):
878 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