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
| 327 | |
| 328 | |
| 329 | class Pool: |
| 330 | """A connection pool. |
| 331 | |
| 332 | Connection pool can be used to manage a set of connections to the database. |
| 333 | Connections are first acquired from the pool, then used, and then released |
| 334 | back to the pool. Once a connection is released, it's reset to close all |
| 335 | open cursors and other resources *except* prepared statements. |
| 336 | |
| 337 | Pools are created by calling :func:`~asyncpg.pool.create_pool`. |
| 338 | """ |
| 339 | |
| 340 | __slots__ = ( |
| 341 | '_queue', '_loop', '_minsize', '_maxsize', |
| 342 | '_init', '_connect', '_reset', '_connect_args', '_connect_kwargs', |
| 343 | '_holders', '_initialized', '_initializing', '_closing', |
| 344 | '_closed', '_connection_class', '_record_class', '_generation', |
| 345 | '_setup', '_max_queries', '_max_inactive_connection_lifetime' |
| 346 | ) |
| 347 | |
| 348 | def __init__(self, *connect_args, |
| 349 | min_size, |
| 350 | max_size, |
| 351 | max_queries, |
| 352 | max_inactive_connection_lifetime, |
| 353 | connect=None, |
| 354 | setup=None, |
| 355 | init=None, |
| 356 | reset=None, |
| 357 | loop, |
| 358 | connection_class, |
| 359 | record_class, |
| 360 | **connect_kwargs): |
| 361 | |
| 362 | if len(connect_args) > 1: |
| 363 | warnings.warn( |
| 364 | "Passing multiple positional arguments to asyncpg.Pool " |
| 365 | "constructor is deprecated and will be removed in " |
| 366 | "asyncpg 0.17.0. The non-deprecated form is " |
| 367 | "asyncpg.Pool(<dsn>, **kwargs)", |
| 368 | DeprecationWarning, stacklevel=2) |
| 369 | |
| 370 | if loop is None: |
| 371 | loop = asyncio.get_event_loop() |
| 372 | self._loop = loop |
| 373 | |
| 374 | if max_size <= 0: |
| 375 | raise ValueError('max_size is expected to be greater than zero') |
| 376 | |
| 377 | if min_size < 0: |
| 378 | raise ValueError( |
| 379 | 'min_size is expected to be greater or equal to zero') |
| 380 | |
| 381 | if min_size > max_size: |
| 382 | raise ValueError('min_size is greater than max_size') |
| 383 | |
| 384 | if max_queries <= 0: |
| 385 | raise ValueError('max_queries is expected to be greater than zero') |
| 386 |
no outgoing calls
no test coverage detected
searching dependent graphs…