Registry / workflow / schedule

schedule

JSON →
library1.2.2pypypi✓ verified 24d ago

Schedule is a lightweight, in-process job scheduler for Python that allows you to schedule tasks to run at specific intervals or times. It aims for a human-readable syntax and is designed for simplicity. The current version is 1.2.2, and it maintains a stable, low-cadence release cycle, indicating a mature and well-tested library.

pip install schedule
INSTALL
IMPORT
SIG · SCHEDULE
S
schedule
workflowpythonv1.2.2
Install
1.7s avg
Import
32ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.032s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.032s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

schedule
import schedule

This quickstart demonstrates how to define simple functions as jobs and schedule them to run at set intervals. The `schedule.run_pending()` call within a `while` loop is crucial for the scheduler to check and execute due jobs. The `time.sleep(1)` prevents the loop from consuming too much CPU.

import schedule import time def greet_job(name): print(f"Hello, {name}!") def farewell_job(): print("Goodbye!") # Schedule a job to run every 5 seconds, passing arguments schedule.every(5).seconds.do(greet_job, 'Alice') # Schedule a job to run once per minute schedule.every().minute.do(farewell_job) print("Scheduler started. Jobs will run in the console.") print("Press Ctrl+C to stop.") try: while True: schedule.run_pending() # Run all jobs that are due time.sleep(1) # Wait one second before checking again except KeyboardInterrupt: print("Scheduler stopped.")
Debug
Known issues
gotchaJobs will only run if `schedule.run_pending()` is called. If you forget to include it in a loop or call it infrequently, scheduled jobs will not execute on time or at all.
fix
Ensure `schedule.run_pending()` is called regularly, typically in a `while True:` loop with a `time.sleep()` for non-blocking applications, or integrated into an event loop.
affects: All versions
gotchaSchedule is an in-process scheduler and does not provide persistence. All scheduled jobs are lost when the Python script terminates. It is not designed to be a standalone service like cron.
fix
To achieve persistence, you would need to re-schedule jobs upon application startup, potentially storing job definitions in a database or configuration file. For long-running background services, consider dedicated job queue systems or OS-level schedulers.
affects: All versions
gotchaLong-running jobs can block the `schedule.run_pending()` call, preventing other jobs from being checked or executed on time. This can lead to scheduling delays or missed jobs.
fix
For jobs that might take a significant amount of time, consider running them in separate threads or processes. Libraries like `schedule_threaded` or custom threading solutions can help delegate job execution to avoid blocking the main scheduler loop.
affects: All versions
Errors
Common errors & fixes
schedule job not running
The scheduler's pending jobs are not continuously checked and executed, typically because `schedule.run_pending()` is not called inside a persistent loop.
fix
Ensure `schedule.run_pending()` is called repeatedly within an infinite loop, usually combined with `time.sleep()` to prevent excessive CPU usage: `while True: schedule.run_pending(); time.sleep(1)`.
AttributeError: 'Job' object has no attribute 'cancel'
Developers attempt to call a `cancel` method directly on the `Job` object returned by `schedule.every(...).do()`, but job cancellation is handled by the `schedule` module itself.
fix
Use `schedule.cancel_job(job_handle)` where `job_handle` is the `Job` object returned when the job was scheduled: `job_handle = schedule.every(...).do(my_func); schedule.cancel_job(job_handle)`.
TypeError: 'NoneType' object is not callable
The scheduled function is mistakenly called immediately when defining the job (e.g., `do(my_function('arg'))`), causing its `None` return value to be passed to `do()` instead of the function reference.
fix
Pass the function reference and its arguments separately to the `do()` method: `schedule.every(...).do(my_function, 'arg1', kwarg='value')`.
Upgrade
Version history
1.2.2latest on PyPI · released May 25, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
60 hits · last 30 days
node
54
OpenAI (training)
1
Resources
schedule — pip install schedule · libregistry