Fixes in. Hooray.
This commit is contained in:
parent
7a3b11dc32
commit
981d3ea933
5 changed files with 2 additions and 60 deletions
|
|
@ -245,7 +245,6 @@ class CRUDService(Generic[T]):
|
||||||
- forward/backward seek via `key` and `backward`
|
- forward/backward seek via `key` and `backward`
|
||||||
Returns a SeekWindow with items, first/last keys, order spec, limit, and optional total.
|
Returns a SeekWindow with items, first/last keys, order spec, limit, and optional total.
|
||||||
"""
|
"""
|
||||||
self._debug_bind("seek_window")
|
|
||||||
session = self.session
|
session = self.session
|
||||||
query, root_alias = self.get_query()
|
query, root_alias = self.get_query()
|
||||||
|
|
||||||
|
|
@ -477,7 +476,6 @@ class CRUDService(Generic[T]):
|
||||||
|
|
||||||
def get(self, id: int, params=None) -> T | None:
|
def get(self, id: int, params=None) -> T | None:
|
||||||
"""Fetch a single row by id with conflict-free eager loading and clean projection."""
|
"""Fetch a single row by id with conflict-free eager loading and clean projection."""
|
||||||
self._debug_bind("get")
|
|
||||||
query, root_alias = self.get_query()
|
query, root_alias = self.get_query()
|
||||||
|
|
||||||
# Defaults so we can build a projection even if params is None
|
# Defaults so we can build a projection even if params is None
|
||||||
|
|
@ -572,7 +570,6 @@ class CRUDService(Generic[T]):
|
||||||
|
|
||||||
def list(self, params=None) -> list[T]:
|
def list(self, params=None) -> list[T]:
|
||||||
"""Offset/limit listing with smart relationship loading and clean projection."""
|
"""Offset/limit listing with smart relationship loading and clean projection."""
|
||||||
self._debug_bind("list")
|
|
||||||
query, root_alias = self.get_query()
|
query, root_alias = self.get_query()
|
||||||
|
|
||||||
# Defaults so we can reference them later even if params is None
|
# Defaults so we can reference them later even if params is None
|
||||||
|
|
|
||||||
|
|
@ -26,32 +26,6 @@ def init_app(app: Flask, *, runtime: CRUDKitRuntime | None = None, config: type[
|
||||||
try:
|
try:
|
||||||
bound_engine = getattr(SessionFactory, "bind", None) or getattr(SessionFactory, "kw", {}).get("bind") or engine
|
bound_engine = getattr(SessionFactory, "bind", None) or getattr(SessionFactory, "kw", {}).get("bind") or engine
|
||||||
pool = bound_engine.pool
|
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:
|
except Exception as e:
|
||||||
print(f"[crudkit.init_app] Failed to attach pool listeners: {e}")
|
print(f"[crudkit.init_app] Failed to attach pool listeners: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,25 +15,6 @@ from .routes.index import init_index_routes
|
||||||
from .routes.listing import init_listing_routes
|
from .routes.listing import init_listing_routes
|
||||||
from .routes.entry import init_entry_routes
|
from .routes.entry import init_entry_routes
|
||||||
|
|
||||||
def _bind_pool_debug(engine):
|
|
||||||
pool = engine.pool
|
|
||||||
eid = id(engine)
|
|
||||||
|
|
||||||
@event.listens_for(pool, "checkout")
|
|
||||||
def _on_checkout(dbapi_con, con_record, con_proxy):
|
|
||||||
try:
|
|
||||||
print(f"POOL CHECKOUT: {pool.status()} engine id= {eid}")
|
|
||||||
except Exception:
|
|
||||||
# pool.status is safe on SQLA 2.x, but let's be defensive
|
|
||||||
print(f"POOL CHECKOUT (no status) engine id= {eid}")
|
|
||||||
|
|
||||||
@event.listens_for(pool, "checkin")
|
|
||||||
def _on_checkin(dbapi_con, con_record):
|
|
||||||
try:
|
|
||||||
print(f"POOL CHECKIN: {pool.status()} engine id= {eid}")
|
|
||||||
except Exception:
|
|
||||||
print(f"POOL CHECKIN (no status) engine id= {eid}")
|
|
||||||
|
|
||||||
def create_app(config_cls=crudkit.DevConfig) -> Flask:
|
def create_app(config_cls=crudkit.DevConfig) -> Flask:
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
@ -43,8 +24,6 @@ def create_app(config_cls=crudkit.DevConfig) -> Flask:
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
|
|
||||||
engine = runtime.engine
|
engine = runtime.engine
|
||||||
print(f"CRUDKit engine id={id(runtime.engine)} url={runtime.engine.url}")
|
|
||||||
_bind_pool_debug(runtime.engine) # ← attach to the real engine’s pool
|
|
||||||
|
|
||||||
# quick status endpoint you can hit while clicking around
|
# quick status endpoint you can hit while clicking around
|
||||||
@app.get("/_db_status")
|
@app.get("/_db_status")
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ def init_index_routes(app):
|
||||||
"fields": [
|
"fields": [
|
||||||
"start_time",
|
"start_time",
|
||||||
"contact.label",
|
"contact.label",
|
||||||
"work_item.label",
|
"work_item.label"
|
||||||
"work_item.device_type.description"
|
|
||||||
],
|
],
|
||||||
"sort": "start_time"
|
"sort": "start_time"
|
||||||
})
|
})
|
||||||
|
|
@ -65,8 +64,7 @@ def init_index_routes(app):
|
||||||
{"field": "contact.label", "label": "Contact",
|
{"field": "contact.label", "label": "Contact",
|
||||||
"link": {"endpoint": "entry.entry", "params": {"id": "{contact.id}", "model": "user"}}},
|
"link": {"endpoint": "entry.entry", "params": {"id": "{contact.id}", "model": "user"}}},
|
||||||
{"field": "work_item.label", "label": "Work Item",
|
{"field": "work_item.label", "label": "Work Item",
|
||||||
"link": {"endpoint": "entry.entry", "params": {"id": "{work_item.id}", "model": "inventory"}}},
|
"link": {"endpoint": "entry.entry", "params": {"id": "{work_item.id}", "model": "inventory"}}}
|
||||||
{"field": "work_item.device_type.description", "label": "Device Type"}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
logs = render_table(work_logs, columns=columns, opts={"object_class": "worklog"})
|
logs = render_table(work_logs, columns=columns, opts={"object_class": "worklog"})
|
||||||
|
|
|
||||||
|
|
@ -125,12 +125,6 @@ def init_listing_routes(app):
|
||||||
except Exception:
|
except Exception:
|
||||||
svc_engine = None
|
svc_engine = None
|
||||||
|
|
||||||
print(
|
|
||||||
"LISTING ENGINES: "
|
|
||||||
f"runtime={id(rt_engine) if rt_engine else None} "
|
|
||||||
f"session_factory.bind={id(sf_engine) if sf_engine else None} "
|
|
||||||
f"service.bind={id(svc_engine) if svc_engine else None}"
|
|
||||||
)
|
|
||||||
# include limit and go
|
# include limit and go
|
||||||
window = service.seek_window(spec | {"limit": limit}, key=key, backward=backward, include_total=True)
|
window = service.seek_window(spec | {"limit": limit}, key=key, backward=backward, include_total=True)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue