Releases the connection back to the pool
(self, connection: AbstractConnection)
| 1644 | raise ConnectionError("Connection not ready") from None |
| 1645 | |
| 1646 | async def release(self, connection: AbstractConnection): |
| 1647 | """Releases the connection back to the pool""" |
| 1648 | # Connections should always be returned to the correct pool, |
| 1649 | # not doing so is an error that will cause an exception here. |
| 1650 | self._in_use_connections.remove(connection) |
| 1651 | |
| 1652 | if connection.should_reconnect(): |
| 1653 | await connection.disconnect() |
| 1654 | |
| 1655 | self._available_connections.append(connection) |
| 1656 | await self._event_dispatcher.dispatch_async( |
| 1657 | AsyncAfterConnectionReleasedEvent(connection) |
| 1658 | ) |
| 1659 | |
| 1660 | # Record state transition: USED -> IDLE |
| 1661 | pool_name = get_pool_name(self) |
| 1662 | await record_connection_count( |
| 1663 | pool_name=pool_name, |
| 1664 | connection_state=ConnectionState.USED, |
| 1665 | counter=-1, |
| 1666 | ) |
| 1667 | await record_connection_count( |
| 1668 | pool_name=pool_name, |
| 1669 | connection_state=ConnectionState.IDLE, |
| 1670 | counter=1, |
| 1671 | ) |
| 1672 | |
| 1673 | async def disconnect(self, inuse_connections: bool = True): |
| 1674 | """ |
no test coverage detected