MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _reset

Method _reset

lib/sqlalchemy/pool/base.py:1405–1446  ·  view source on GitHub ↗
(
        self,
        pool: Pool,
        transaction_was_reset: bool,
        terminate_only: bool,
        asyncio_safe: bool,
    )

Source from the content-addressed store, hash-verified

1403 self._checkin()
1404
1405 def _reset(
1406 self,
1407 pool: Pool,
1408 transaction_was_reset: bool,
1409 terminate_only: bool,
1410 asyncio_safe: bool,
1411 ) -> None:
1412 if pool.dispatch.reset:
1413 pool.dispatch.reset(
1414 self.dbapi_connection,
1415 self._connection_record,
1416 PoolResetState(
1417 transaction_was_reset=transaction_was_reset,
1418 terminate_only=terminate_only,
1419 asyncio_safe=asyncio_safe,
1420 ),
1421 )
1422
1423 if not asyncio_safe:
1424 return
1425
1426 if pool._reset_on_return is reset_rollback:
1427 if transaction_was_reset:
1428 if self._echo:
1429 pool.logger.debug(
1430 "Connection %s reset, transaction already reset",
1431 self.dbapi_connection,
1432 )
1433 else:
1434 if self._echo:
1435 pool.logger.debug(
1436 "Connection %s rollback-on-return",
1437 self.dbapi_connection,
1438 )
1439 pool._dialect.do_rollback(self)
1440 elif pool._reset_on_return is reset_commit:
1441 if self._echo:
1442 pool.logger.debug(
1443 "Connection %s commit-on-return",
1444 self.dbapi_connection,
1445 )
1446 pool._dialect.do_commit(self)
1447
1448 @property
1449 def _logger(self) -> log._IdentifiedLoggerType:

Callers 1

_finalize_fairyFunction · 0.45

Calls 5

PoolResetStateClass · 0.85
debugMethod · 0.80
resetMethod · 0.45
do_rollbackMethod · 0.45
do_commitMethod · 0.45

Tested by

no test coverage detected