MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _close_connection

Method _close_connection

lib/sqlalchemy/pool/base.py:363–384  ·  view source on GitHub ↗
(
        self, connection: DBAPIConnection, *, terminate: bool = False
    )

Source from the content-addressed store, hash-verified

361 return lambda rec: creator_fn()
362
363 def _close_connection(
364 self, connection: DBAPIConnection, *, terminate: bool = False
365 ) -> None:
366 self.logger.debug(
367 "%s connection %r",
368 "Hard-closing" if terminate else "Closing",
369 connection,
370 )
371 try:
372 if terminate:
373 self._dialect.do_terminate(connection)
374 else:
375 self._dialect.do_close(connection)
376 except BaseException as e:
377 self.logger.error(
378 f"Exception {'terminating' if terminate else 'closing'} "
379 f"connection %r",
380 connection,
381 exc_info=True,
382 )
383 if not isinstance(e, Exception):
384 raise
385
386 def _create_connection(self) -> ConnectionPoolEntry:
387 """Called by subclasses to create a new ConnectionRecord."""

Callers 2

__closeMethod · 0.80
_finalize_fairyFunction · 0.80

Calls 4

debugMethod · 0.80
errorMethod · 0.80
do_terminateMethod · 0.45
do_closeMethod · 0.45

Tested by

no test coverage detected