(self)
| 443 | self._initialized = True |
| 444 | |
| 445 | async def _initialize(self): |
| 446 | self._queue = asyncio.LifoQueue(maxsize=self._maxsize) |
| 447 | for _ in range(self._maxsize): |
| 448 | ch = PoolConnectionHolder( |
| 449 | self, |
| 450 | max_queries=self._max_queries, |
| 451 | max_inactive_time=self._max_inactive_connection_lifetime, |
| 452 | setup=self._setup) |
| 453 | |
| 454 | self._holders.append(ch) |
| 455 | self._queue.put_nowait(ch) |
| 456 | |
| 457 | if self._minsize: |
| 458 | # Since we use a LIFO queue, the first items in the queue will be |
| 459 | # the last ones in `self._holders`. We want to pre-connect the |
| 460 | # first few connections in the queue, therefore we want to walk |
| 461 | # `self._holders` in reverse. |
| 462 | |
| 463 | # Connect the first connection holder in the queue so that |
| 464 | # any connection issues are visible early. |
| 465 | first_ch = self._holders[-1] # type: PoolConnectionHolder |
| 466 | await first_ch.connect() |
| 467 | |
| 468 | if self._minsize > 1: |
| 469 | connect_tasks = [] |
| 470 | for i, ch in enumerate(reversed(self._holders[:-1])): |
| 471 | # `minsize - 1` because we already have first_ch |
| 472 | if i >= self._minsize - 1: |
| 473 | break |
| 474 | connect_tasks.append(ch.connect()) |
| 475 | |
| 476 | await asyncio.gather(*connect_tasks) |
| 477 | |
| 478 | def is_closing(self): |
| 479 | """Return ``True`` if the pool is closing or is closed. |
no test coverage detected