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

Method _async__init__

asyncpg/pool.py:486–507  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

484 max_inactive_connection_lifetime
485
486 async def _async__init__(self):
487 if self._initialized:
488 return self
489 if self._initializing:
490 raise exceptions.InterfaceError(
491 'pool is being initialized in another task')
492 if self._closed:
493 raise exceptions.InterfaceError('pool is closed')
494 self._initializing = True
495 try:
496 await self._initialize()
497 return self
498 except (Exception, asyncio.CancelledError):
499 # Failed initialization must not leave warm connections behind.
500 self._closed = True
501 for holder in self._holders:
502 holder.terminate()
503 raise
504 finally:
505 self._initializing = False
506 self._initialized = True
507 self._schedule_min_size_maintenance()
508
509 async def _initialize(self):
510 self._queue = _PoolConnectionHolderQueue(maxsize=self._maxsize)

Callers 2

__await__Method · 0.95
__aenter__Method · 0.95

Calls 3

_initializeMethod · 0.95
terminateMethod · 0.45

Tested by

no test coverage detected