MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _close_connection

Method _close_connection

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

Source from the content-addressed store, hash-verified

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