Fixes in. Hooray.
This commit is contained in:
parent
7a3b11dc32
commit
981d3ea933
5 changed files with 2 additions and 60 deletions
|
|
@ -26,32 +26,6 @@ def init_app(app: Flask, *, runtime: CRUDKitRuntime | None = None, config: type[
|
|||
try:
|
||||
bound_engine = getattr(SessionFactory, "bind", None) or getattr(SessionFactory, "kw", {}).get("bind") or engine
|
||||
pool = bound_engine.pool
|
||||
|
||||
from sqlalchemy import event
|
||||
|
||||
@event.listens_for(pool, "checkout")
|
||||
def _on_checkout(dbapi_conn, conn_record, conn_proxy):
|
||||
sz = pool.size()
|
||||
chk = pool.checkedout()
|
||||
try:
|
||||
conns_in_pool = pool.checkedin()
|
||||
except Exception:
|
||||
conns_in_pool = "?"
|
||||
print(f"POOL CHECKOUT: Pool size: {sz} Connections in pool: {conns_in_pool} "
|
||||
f"Current Overflow: {pool.overflow()} Current Checked out connections: {chk} "
|
||||
f"engine id= {id(bound_engine)}")
|
||||
|
||||
@event.listens_for(pool, "checkin")
|
||||
def _on_checkin(dbapi_conn, conn_record):
|
||||
sz = pool.size()
|
||||
chk = pool.checkedout()
|
||||
try:
|
||||
conns_in_pool = pool.checkedin()
|
||||
except Exception:
|
||||
conns_in_pool = "?"
|
||||
print(f"POOL CHECKIN: Pool size: {sz} Connections in pool: {conns_in_pool} "
|
||||
f"Current Overflow: {pool.overflow()} Current Checked out connections: {chk} "
|
||||
f"engine id= {id(bound_engine)}")
|
||||
except Exception as e:
|
||||
print(f"[crudkit.init_app] Failed to attach pool listeners: {e}")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue