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

Method close_connections

tortoise/context.py:470–485  ·  view source on GitHub ↗

Close all database connections owned by this context. This is called automatically when exiting the async context manager. Also clears the global fallback if this context was set as global.

(self)

Source from the content-addressed store, hash-verified

468 return self.connections.get(connection_name)
469
470 async def close_connections(self) -> None:
471 """
472 Close all database connections owned by this context.
473
474 This is called automatically when exiting the async context manager.
475 Also clears the global fallback if this context was set as global.
476 """
477 global _global_context
478 if self._connections is not None:
479 # Only close if connections were actually initialized
480 if self._connections._db_config is not None:
481 await self._connections.close_all(discard=True)
482 self._connections = None
483 # Clear global context if this context was set as the global fallback
484 if _global_context is self:
485 _global_context = None
486
487 def __enter__(self) -> TortoiseContext:
488 """

Callers 2

__aexit__Method · 0.95
initMethod · 0.95

Calls 1

close_allMethod · 0.80

Tested by

no test coverage detected