Closes all connections in the storage in the `current context`. All closed connections will be removed from the storage by default. :param discard: If ``False``, all connection objects are closed but `retained` in the storage.
(self, discard: bool = True)
| 262 | return [self.get(alias) for alias in self.db_config] |
| 263 | |
| 264 | async def close_all(self, discard: bool = True) -> None: |
| 265 | """ |
| 266 | Closes all connections in the storage in the `current context`. |
| 267 | |
| 268 | All closed connections will be removed from the storage by default. |
| 269 | |
| 270 | :param discard: |
| 271 | If ``False``, all connection objects are closed but `retained` in the storage. |
| 272 | """ |
| 273 | # Handle case where connections were never initialized (e.g., init failed) |
| 274 | if self._db_config is None: |
| 275 | return |
| 276 | tasks = [conn.close() for conn in self.all()] |
| 277 | await asyncio.gather(*tasks) |
| 278 | if discard: |
| 279 | for alias in self.db_config: |
| 280 | self.discard(alias) |
| 281 | |
| 282 | |
| 283 | class _ConnectionsProxy: |