MCPcopy
hub / github.com/tortoise/tortoise-orm / close_all

Method close_all

tortoise/connection.py:264–280  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
283class _ConnectionsProxy:

Callers 6

close_connectionsMethod · 0.80
_drop_databasesMethod · 0.80
mainFunction · 0.80
test_schemaFunction · 0.80

Calls 3

allMethod · 0.95
discardMethod · 0.95
closeMethod · 0.45

Tested by 3

test_schemaFunction · 0.64