Skip to main content

A powerful yet simple Python task scheduler

Project description

PyScheduler

The simplest and most powerful Python scheduler

PyPI version Python versions License: MIT

PyScheduler revolutionizes task scheduling in Python. 3 lines are enough to get started, yet it offers all the power needed for production.

โœจ Features

  • ๐ŸŽฏ Ultra-simple: Get started in 30 seconds
  • โšก High-performance: Optimized threading, native async tasks
  • ๐Ÿ›ก๏ธ Robust: Automatic retry, advanced error handling
  • ๐Ÿ“Š Comprehensive: Detailed logs, monitoring, statistics
  • ๐Ÿ• Flexible: Intervals, CRON, one-off tasks
  • ๐Ÿ“„ Production-ready: YAML configuration, integrated CLI

๐Ÿš€ Installation

pip install pyscheduler[full]
Minimal installation (without optional dependencies)
pip install pyscheduler

โšก Quick Start

from pyscheduler import PyScheduler, task

@task(60)  # Every minute
def backup_data():
    print("Automatic backup!")

@task(cron="0 9 * * 1-5")  # 9 AM on weekdays
def send_report():
    print("Daily report sent")

# That's it! ๐ŸŽ‰
scheduler = PyScheduler()
scheduler.start()

๐Ÿ“‹ Usage Examples

Simple Tasks

from pyscheduler import task, daily, startup

@task(30)  # Every 30 seconds
def health_check():
    return check_system_health()

@daily("02:00")  # Every day at 2 AM
def daily_backup():
    return backup_database()

@startup()  # On startup
def init_app():
    return initialize_application()

Advanced Configuration

from pyscheduler import PyScheduler
from pyscheduler.config import RetryConfig, Priority

scheduler = PyScheduler(log_level="INFO")

scheduler.add_task(
    func=critical_task,
    interval=300,  # 5 minutes
    priority=Priority.CRITICAL,
    timeout=60,
    retry_config=RetryConfig(max_attempts=3, backoff_factor=2.0)
)

YAML Configuration

# scheduler_config.yaml
global_settings:
  timezone: "Europe/Paris"
  log_level: "INFO"
  max_workers: 10

tasks:
  - name: "backup_task"
    module: "myapp.tasks"
    function: "backup_database"
    schedule:
      type: "cron"
      value: "0 2 * * *"  # 2 AM
    priority: "HIGH"
    timeout: 3600
scheduler = PyScheduler(config_file="scheduler_config.yaml")
scheduler.start()

๐ŸŽช Use Cases

Need PyScheduler Solution
๐Ÿ”„ Periodic Tasks @task(interval=60)
โฐ Precise Scheduling @task(cron="0 9 * * 1-5")
๐Ÿš€ Startup/Shutdown Tasks @startup() / @shutdown()
โšก Asynchronous Tasks Native async def support
๐Ÿ›ก๏ธ Robustness Automatic retry, timeouts
๐Ÿ“Š Production Logs, stats, monitoring

๐Ÿ“š Full Documentation

๐Ÿƒโ€โ™‚๏ธ Quick Examples

Get started with included examples

# After installation
python -c "from pyscheduler.examples import basic_usage; basic_usage.main()"

Real-time Monitoring

with PyScheduler() as scheduler:
    # Your tasks here
    scheduler.run_forever()  # Ctrl+C to stop

๐Ÿš€ Advanced Features

๐ŸŽฏ Priorities and Threading
from pyscheduler.config import Priority

@task(interval=60, priority=Priority.CRITICAL)
def critical_health_check():
    return monitor_critical_systems()

@task(interval=300, priority=Priority.LOW)
def cleanup_temp_files():
    return cleanup_operations()
โšก Asynchronous Tasks
@task(interval=30)
async def async_api_calls():
    async with aiohttp.ClientSession() as session:
        tasks = [fetch_data(session, url) for url in urls]
        return await asyncio.gather(*tasks)
๐Ÿ›ก๏ธ Robust Error Handling
from pyscheduler.config import RetryConfig

@task(
    interval=120,
    retry_config=RetryConfig(
        max_attempts=5,
        backoff_factor=2.0,
        max_delay=300
    ),
    timeout=60
)
def unreliable_external_api():
    return call_external_service()

๐Ÿ”ฅ Why PyScheduler?

Problem PyScheduler Solution
๐Ÿ˜ฉ APScheduler too complex โœ… 3 lines to get started
๐ŸŒ Celery is overkill โœ… Zero configuration Redis/broker
๐Ÿ”ง Cron is limited โœ… Native Python + cron expressions
๐Ÿ“Š No monitoring โœ… Detailed logs + statistics
๐Ÿšซ No retry โœ… Smart retry built-in

๐Ÿ† Performance

  • โšก Startup: < 100ms
  • ๐Ÿ’พ Memory: < 20MB for 100 tasks
  • ๐Ÿ”„ Concurrency: Up to 1000 parallel tasks
  • ๐ŸŽฏ Precision: ยฑ50ms on schedules

๐Ÿค Contributing

We welcome all contributions!

git clone https://github.com/Tiger-Foxx/PyScheduler.git
cd PyScheduler
pip install -e .[dev]
pytest

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ™ Acknowledgments

Inspired by the best scheduling tools, designed for Pythonic simplicity.


โญ If PyScheduler helps you, feel free to star the repo!

๐Ÿ  Homepage โ€ข ๐Ÿ“š Documentation โ€ข ๐Ÿ› Issues โ€ข ๐Ÿ’ฌ Discussions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyscheduler_fox-1.0.0.tar.gz (80.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyscheduler_fox-1.0.0-py3-none-any.whl (89.2 kB view details)

Uploaded Python 3

File details

Details for the file pyscheduler_fox-1.0.0.tar.gz.

File metadata

  • Download URL: pyscheduler_fox-1.0.0.tar.gz
  • Upload date:
  • Size: 80.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for pyscheduler_fox-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c78aa93f533c8fe2e10958bf162bc0fc4e43516e70b003b9135398c303cd6614
MD5 e25afd49fd3a389d49aa7f64051b14c4
BLAKE2b-256 068e827cf94e02b4179949b102da10710299df806a600d461ec64b4d0a5b6517

See more details on using hashes here.

File details

Details for the file pyscheduler_fox-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyscheduler_fox-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a0a7209499c7b24b4ab14e150eed832bc89273cdf97f1c5a8f0d889f6d940c8
MD5 cfbb9c0743435b96bef8dd030677c35f
BLAKE2b-256 3e7c8b3998627cea19cbd34f7a5db46ba2e35192443619074d9a8ad5cf344597

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page