Skip to content

Sleep only between jobs in run_all - #661

Closed
Eric3-jp wants to merge 1 commit into
dbader:masterfrom
Eric3-jp:fix/run-all-delay-between-jobs
Closed

Eric3-jp wants to merge 1 commit into
dbader:masterfrom
Eric3-jp:fix/run-all-delay-between-jobs

Conversation

@Eric3-jp

Copy link
Copy Markdown

run_all(delay_seconds=10) currently sleeps after the final job, including when only one job is scheduled. With two immediate jobs, the call waits 20 seconds although the documented delay is between jobs.

Move the sleep before the second and subsequent jobs. The first job still starts immediately, jobs remain separated by the requested delay, and the method returns when the last job finishes. Iteration still uses self.jobs[:], preserving the existing snapshot behavior when a callback adds or removes jobs.

Added regressions use mocked sleep to verify the event sequence for zero, one, and three jobs, plus a callback that clears and replaces the schedule. The original implementation fails three assertions; the change makes them pass without waiting in real time.

Validation on Ubuntu 24.04 (WSL), CPython 3.12.3:

  • python -m pytest test_schedule.py schedule -q --cov schedule --cov-report term-missing: 83 passed, 3 subtests passed, including the timezone tests; 99% coverage.
  • python -m mypy -p schedule: no issues in 1 source file.
  • Repository-pinned Black 20.8b1 on CPython 3.11.16: all four tracked Python files pass --check.
  • git diff --check passes.
  • The full supported-interpreter tox matrix has not been run locally.

OpenAI Codex assisted with the investigation, patch, tests, and this description. The reported checks were executed locally.

@Eric3-jp Eric3-jp closed this by deleting the head repository Sep 23, 2026
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