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

Class Pool

asyncpg/pool.py:369–1166  ·  view source on GitHub ↗

A connection pool. Connection pool can be used to manage a set of connections to the database. Connections are first acquired from the pool, then used, and then released back to the pool. Once a connection is released, it's reset to close all open cursors and other resources *excep

Source from the content-addressed store, hash-verified

367
368
369class Pool:
370 """A connection pool.
371
372 Connection pool can be used to manage a set of connections to the database.
373 Connections are first acquired from the pool, then used, and then released
374 back to the pool. Once a connection is released, it's reset to close all
375 open cursors and other resources *except* prepared statements.
376
377 Pools are created by calling :func:`~asyncpg.pool.create_pool`.
378 """
379
380 __slots__ = (
381 '_queue', '_loop', '_initsize', '_minsize', '_maxsize',
382 '_init', '_connect', '_reset', '_connect_args', '_connect_kwargs',
383 '_holders', '_initialized', '_initializing', '_closing',
384 '_closed', '_connection_class', '_record_class', '_generation',
385 '_setup', '_max_queries', '_max_inactive_connection_lifetime',
386 '_maintenance_task',
387 )
388
389 def __init__(self, *connect_args,
390 init_size=None,
391 min_size,
392 max_size,
393 max_queries,
394 max_inactive_connection_lifetime,
395 connect=None,
396 setup=None,
397 init=None,
398 reset=None,
399 loop,
400 connection_class,
401 record_class,
402 **connect_kwargs):
403
404 if len(connect_args) > 1:
405 warnings.warn(
406 "Passing multiple positional arguments to asyncpg.Pool "
407 "constructor is deprecated and will be removed in "
408 "asyncpg 0.17.0. The non-deprecated form is "
409 "asyncpg.Pool(<dsn>, **kwargs)",
410 DeprecationWarning, stacklevel=2)
411
412 if loop is None:
413 loop = asyncio.get_event_loop()
414 self._loop = loop
415
416 if max_size <= 0:
417 raise ValueError('max_size is expected to be greater than zero')
418
419 if min_size < 0:
420 raise ValueError(
421 'min_size is expected to be greater or equal to zero')
422
423 if min_size > max_size:
424 raise ValueError('min_size is greater than max_size')
425
426 if init_size is None:

Callers 1

create_poolFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected