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

Method _invalidate

lib/sqlalchemy/pool/base.py:391–411  ·  view source on GitHub ↗

Mark all connections established within the generation of the given connection as invalidated. If this pool's last invalidate time is before when the given connection was created, update the timestamp til now. Otherwise, no action is performed. Connections

(
        self,
        connection: PoolProxiedConnection,
        exception: Optional[BaseException] = None,
        _checkin: bool = True,
    )

Source from the content-addressed store, hash-verified

389 return _ConnectionRecord(self)
390
391 def _invalidate(
392 self,
393 connection: PoolProxiedConnection,
394 exception: Optional[BaseException] = None,
395 _checkin: bool = True,
396 ) -> None:
397 """Mark all connections established within the generation
398 of the given connection as invalidated.
399
400 If this pool's last invalidate time is before when the given
401 connection was created, update the timestamp til now. Otherwise,
402 no action is performed.
403
404 Connections with a start time prior to this pool's invalidation
405 time will be recycled upon next checkout.
406 """
407 rec = getattr(connection, "_connection_record", None)
408 if not rec or self._invalidate_time < rec.starttime:
409 self._invalidate_time = time.time()
410 if _checkin and getattr(connection, "is_valid", False):
411 connection.invalidate(exception)
412
413 def recreate(self) -> Pool:
414 """Return a new :class:`_pool.Pool`, of the same class as this one

Calls 2

timeMethod · 0.45
invalidateMethod · 0.45