Skip to content

Add optional on_check callback to Job.join()#125

Merged
ad-m merged 2 commits intomasterfrom
add-on-check-callback
Mar 7, 2026
Merged

Add optional on_check callback to Job.join()#125
ad-m merged 2 commits intomasterfrom
add-on-check-callback

Conversation

@ad-m
Copy link
Owner

@ad-m ad-m commented Mar 7, 2026

Summary

  • Add an optional on_check callback parameter to Job.join() that is called after each polling iteration with (elapsed_time, status)
  • Enables progress logging, progress bars, or custom monitoring during the blocking join() call
  • Fully backward compatible — defaults to None, no behavior change if not provided

Usage

# Simple progress logging
job.join(on_check=lambda elapsed, status: print(f"Waiting... {elapsed}s ({status})"))

# Or with a progress bar
from tqdm import tqdm
bar = tqdm(total=300, unit="s")
job.join(on_check=lambda elapsed, status: bar.update(3))

Test plan

  • Callback is invoked on each non-ready polling iteration with correct elapsed time and status
  • No error when on_check is not provided (backward compatibility)
  • Callback is not called when task is immediately ready

🤖 Generated with Claude Code

Adam Dobrawy and others added 2 commits March 7, 2026 14:22
Allow users to monitor progress during the blocking join() call by
passing an on_check callback that receives (elapsed_time, status)
after each polling iteration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ad-m ad-m merged commit 11b67b4 into master Mar 7, 2026
6 of 7 checks passed
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