Skip to content

Lease manager centralized#402

Closed
v1r3n wants to merge 4 commits intomainfrom
lease-manager-centralized
Closed

Lease manager centralized#402
v1r3n wants to merge 4 commits intomainfrom
lease-manager-centralized

Conversation

@v1r3n
Copy link
Copy Markdown
Contributor

@v1r3n v1r3n commented Apr 21, 2026

No description provided.

v1r3n and others added 4 commits April 20, 2026 13:35
…oll loop

Replace inline heartbeat logic in both TaskRunner and AsyncTaskRunner
with a process-wide LeaseManager singleton. A background daemon thread
checks for due heartbeats at ~1s intervals and dispatches them to a
ThreadPoolExecutor(4), so heartbeat API calls and retries never block
task polling.

Key changes:
- LeaseManager: singleton with background thread + thread pool, fork-safe
  via PID check, lazy start on first track() call
- TaskRunner: delegates to LeaseManager.track/untrack instead of inline
  _send_due_heartbeats/_send_heartbeat methods
- AsyncTaskRunner: same delegation; creates a sync TaskResourceApi for
  LeaseManager since heartbeats run in the thread pool, not the event loop
- task_handler.py: clean — no LeaseManager knowledge needed
- 21 unit tests covering track/untrack, heartbeat dispatch, retries,
  non-blocking behavior, singleton/fork safety, thread safety

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Three tests against a live Conductor server:
1. Async task with heartbeat → COMPLETED (50s sleep, 10s timeout)
2. Async task without heartbeat → TIMED_OUT
3. Performance: heartbeat tracking adds 0ms overhead on fast tasks
@v1r3n v1r3n closed this Apr 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 57 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant