{"id":1703,"library":"schedule","title":"Schedule","description":"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.","status":"active","version":"1.2.2","language":"en","source_language":"en","source_url":"https://github.com/dbader/schedule.git","tags":["scheduling","jobs","tasks","automation"],"install":[{"cmd":"pip install schedule","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"schedule","correct":"import schedule"}],"quickstart":{"code":"import schedule\nimport time\n\ndef greet_job(name):\n    print(f\"Hello, {name}!\")\n\ndef farewell_job():\n    print(\"Goodbye!\")\n\n# Schedule a job to run every 5 seconds, passing arguments\nschedule.every(5).seconds.do(greet_job, 'Alice')\n\n# Schedule a job to run once per minute\nschedule.every().minute.do(farewell_job)\n\nprint(\"Scheduler started. Jobs will run in the console.\")\nprint(\"Press Ctrl+C to stop.\")\n\ntry:\n    while True:\n        schedule.run_pending() # Run all jobs that are due\n        time.sleep(1) # Wait one second before checking again\nexcept KeyboardInterrupt:\n    print(\"Scheduler stopped.\")","lang":"python","description":"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."},"warnings":[{"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.","message":"Jobs 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Schedule 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"Long-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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}