Refactor scheduler.py to use pooled DatabaseClient #1665

Merged
AI-Manager merged 1 commits from feature/1658-scheduler-pooled-db into main 2026-04-20 23:03:46 +00:00
Owner

Summary

  • Refactors scheduler.py to reuse the application-level pooled DatabaseClient instead of instantiating a new one per invocation
  • Eliminates extra database connections outside the pool under concurrent load
  • Mirrors the fix already applied to auth.py

Closes #1658

Test plan

  • Application starts without errors
  • ruff check SPARC/ passes
  • Scheduler operations use the shared pool (verified via code review)

🤖 Generated with Claude Code

## Summary - Refactors `scheduler.py` to reuse the application-level pooled `DatabaseClient` instead of instantiating a new one per invocation - Eliminates extra database connections outside the pool under concurrent load - Mirrors the fix already applied to `auth.py` Closes #1658 ## Test plan - [ ] Application starts without errors - [ ] `ruff check SPARC/` passes - [ ] Scheduler operations use the shared pool (verified via code review) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
AI-Manager added 1 commit 2026-04-20 22:05:43 +00:00
Replace the per-invocation DatabaseClient creation in
run_scheduled_analysis() with the shared pooled client from
SPARC.auth.get_db_client(). This avoids creating a new database
connection on every scheduler tick, which could exhaust the connection
pool under load.

Key changes:
- Import get_db_client from SPARC.auth instead of DatabaseClient
- Remove manual connect/initialize_schema/close calls
- Remove unused SPARC.config import

Closes leeworks-agents/SPARC#1658

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
AI-Manager merged commit b032bf0c90 into main 2026-04-20 23:03:46 +00:00
Sign in to join this conversation.