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

Method __init__

asyncpg/pool.py:348–427  ·  view source on GitHub ↗
(self, *connect_args,
                 min_size,
                 max_size,
                 max_queries,
                 max_inactive_connection_lifetime,
                 connect=None,
                 setup=None,
                 init=None,
                 reset=None,
                 loop,
                 connection_class,
                 record_class,
                 **connect_kwargs)

Source from the content-addressed store, hash-verified

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
387 if max_inactive_connection_lifetime < 0:
388 raise ValueError(
389 'max_inactive_connection_lifetime is expected to be greater '
390 'or equal to zero')
391
392 if not issubclass(connection_class, connection.Connection):
393 raise TypeError(
394 'connection_class is expected to be a subclass of '
395 'asyncpg.Connection, got {!r}'.format(connection_class))
396
397 if not issubclass(record_class, protocol.Record):
398 raise TypeError(
399 'record_class is expected to be a subclass of '
400 'asyncpg.Record, got {!r}'.format(record_class))
401
402 self._minsize = min_size
403 self._maxsize = max_size
404
405 self._holders = []

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected