MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _invalidate

Method _invalidate

lib/sqlalchemy/pool/base.py:389–409  ·  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

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

Calls 2

timeMethod · 0.45
invalidateMethod · 0.45