Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Uses python AppScheduler, ZeroRpc, and tornado to compose a simple cross-platform job scheduler server. Register your separate job executors then view and control scheduled jobs from one place.

Notifications You must be signed in to change notification settings

esotericbyte/ScheduleZero

Repository files navigation

⏰ ScheduleZero

Lightweight Distributed Task Scheduling for Python

Python 3.12+ License: MIT Code style: black

Features β€’ Quick Start β€’ Architecture β€’ Documentation β€’ API


🎯 Overview

ScheduleZero is a resource-conscious, distributed task scheduling system built entirely in Python. Perfect for scenarios where heavyweight solutions like Celery are overkillβ€”especially on memory-constrained systems like small VMs or edge devices.

Why ScheduleZero?

  • πŸͺΆ Lightweight: No message broker required (RabbitMQ/Redis)
  • πŸš€ Fast: Built on modern async Python (asyncio, Tornado)
  • πŸ”„ Distributed: Scale horizontally with worker handlers
  • πŸ’Ύ Persistent: SQLite-based job storage
  • 🎨 Beautiful UI: Modern web interface for monitoring
  • πŸ”Œ Brokerless: Direct RPC communication via zerorpc
  • πŸ›‘οΈ Reliable: Built-in retry logic with exponential backoff

✨ Features

Core Capabilities

  • πŸ• Flexible Scheduling: Date, interval, and cron triggers via APScheduler 4.x
  • πŸ“‘ Remote Execution: Distribute jobs across multiple handler processes
  • πŸ”„ Auto-Discovery: Handlers self-register with the central server
  • πŸ’ͺ Resilient: Automatic retries with exponential backoff + jitter
  • πŸ“Š REST API: Full HTTP API for programmatic control
  • πŸŽ›οΈ Web Dashboard: Real-time monitoring and job management
  • πŸ’Ύ Persistent Storage: Jobs survive restarts via SQLite
  • πŸ” Thread-Safe: Concurrent job execution with proper locking

Advanced Features

  • Dynamic Handler Registration: Add/remove workers on-the-fly
  • Method-Level Routing: Route jobs to specific handler methods
  • Status Tracking: Monitor handler availability and job execution
  • Configuration Management: YAML-based instance configuration
  • Graceful Shutdown: Clean termination of all components
  • Exponential Backoff: Smart retry logic for failed jobs

πŸš€ Quick Start

Installation

# Using Poetry (recommended)
poetry install

# Or using pip
pip install -r requirements.txt

Configuration

Create config.yaml in your project root:

instance_name: "My ScheduleZero Instance"
description: "Production task scheduler"
admin_contact: "[email protected]"
version: "1.0.0"

Running

Terminal 1 - Start the Server:

poetry run schedule-zero-server
# Server starts on http://127.0.0.1:8888

Terminal 2 - Start a Handler:

poetry run schedule-zero-handler
# Handler auto-registers and starts listening

Terminal 3 - Test the System:

poetry run python test_schedule.py
# Runs end-to-end tests

Access the Dashboard

Open your browser to http://localhost:8888


πŸ—οΈ Architecture

Component Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               ScheduleZero Central Server               β”‚
β”‚                                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   Tornado    β”‚  β”‚  APScheduler β”‚  β”‚   zerorpc    β”‚  β”‚
β”‚  β”‚  Web Server  │──│   4.x Async  │──│Registration  β”‚  β”‚
β”‚  β”‚   :8888      β”‚  β”‚   Scheduler  β”‚  β”‚Server :4242  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                  β”‚                  β”‚          β”‚
β”‚         β”‚                  β”‚                  β”‚          β”‚
β”‚    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”‚
β”‚    β”‚   HTTP   β”‚      β”‚  SQLite   β”‚     β”‚ Handler   β”‚  β”‚
β”‚    β”‚   API    β”‚      β”‚  JobStore β”‚     β”‚ Registry  β”‚  β”‚
β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                          β”‚  zerorpc (tcp)
                          β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                                   β”‚
        β–Ό                                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Handler 1   β”‚                   β”‚   Handler 2   β”‚
β”‚   :4243       β”‚                   β”‚   :4244       β”‚
β”‚               β”‚                   β”‚               β”‚
β”‚  β€’ do_work()  β”‚                   β”‚  β€’ process()  β”‚
β”‚  β€’ backup()   β”‚                   β”‚  β€’ analyze()  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

Component Technology Purpose
Web Framework Tornado 6.5+ Async web server & HTTP API
Scheduler APScheduler 4.x Job scheduling & execution
RPC Layer zerorpc Lightweight, brokerless communication
Persistence SQLite + SQLAlchemy Job storage & retrieval
Transport ZeroMQ High-performance messaging
Serialization MessagePack Efficient data encoding
Configuration PyYAML Human-readable config files

Why These Choices?

πŸŒͺ️ Tornado

  • Native asyncio support for APScheduler 4.x integration
  • Efficient async I/O for handling many connections
  • Built-in web serverβ€”no external dependencies

πŸ“… APScheduler 4.x

  • Modern async-first design
  • Flexible trigger types (date, interval, cron)
  • Persistent job storage with datastore abstraction

πŸ”Œ zerorpc

  • No message broker required (unlike Celery)
  • Minimal memory footprint
  • Built-in heartbeat and timeout handling
  • Automatic serialization with MessagePack

πŸ’Ύ SQLite

  • Zero configuration database
  • Low memory usage (< 1MB typical)
  • Perfect for embedded/edge deployments
  • ACID transactions for reliability

πŸ“– Documentation

File Structure (After Refactoring)

src/schedule_zero/
β”œβ”€β”€ app_configuration.py          # App config & environment vars
β”œβ”€β”€ handler_registry.py            # Handler registration & clients
β”œβ”€β”€ job_executor.py                # Job execution with retries
β”œβ”€β”€ zerorpc_registration_server.py # RPC server for registration
β”œβ”€β”€ tornado_app_server.py          # Main server orchestration
β”œβ”€β”€ server.py                      # CLI entry point
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ tornado_base_handlers.py   # Base Tornado handlers
β”‚   β”œβ”€β”€ handler_list_api.py        # Handler endpoints
β”‚   β”œβ”€β”€ job_scheduling_api.py      # Job scheduling endpoints
β”‚   └── config_api.py              # Configuration endpoint
└── handlers/
    β”œβ”€β”€ base.py                    # Abstract handler base class
    └── example.py                 # Example handler implementation

Documentation Files:


πŸ”Œ API Reference

Handler Management

List Handlers

GET /api/handlers

Response:

{
  "handlers": [
    {
      "id": "handler_12345",
      "address": "tcp://127.0.0.1:4243",
      "methods": ["do_work", "backup", "process"],
      "status": "Connected"
    }
  ]
}

Job Scheduling

Schedule a Job

POST /api/schedule
Content-Type: application/json

{
  "handler_id": "handler_12345",
  "method_name": "do_work",
  "job_params": {
    "input_file": "/data/file.txt",
    "output_dir": "/results/"
  },
  "trigger_config": {
    "type": "interval",
    "hours": 1
  }
}

Response:

{
  "status": "success",
  "schedule_id": "job_67890"
}

Run Job Immediately

POST /api/run_now
Content-Type: application/json

{
  "handler_id": "handler_12345",
  "method_name": "do_work",
  "job_params": {
    "message": "Hello World"
  }
}

List Schedules

GET /api/schedules

Response:

{
  "schedules": [
    {
      "id": "job_67890",
      "next_fire_time": "2025-10-27T15:30:00Z",
      "trigger": "interval[1:00:00]",
      "args": ["handler_12345", "do_work", {...}]
    }
  ],
  "count": 1
}

Configuration

Get Server Config

GET /api/config

Health Check

GET /api/health

πŸ”§ Configuration

Environment Variables

Variable Default Description
SCHEDULEZERO_TORNADO_ADDR 127.0.0.1 Tornado bind address
SCHEDULEZERO_TORNADO_PORT 8888 Tornado HTTP port
SCHEDULEZERO_ZRPC_HOST 127.0.0.1 zerorpc server host
SCHEDULEZERO_ZRPC_PORT 4242 zerorpc server port
SCHEDULEZERO_DATABASE_URL sqlite:///schedulezero_jobs.db Database connection
SCHEDULEZERO_CONFIG_PATH config.yaml Config file path
SCHEDULEZERO_REGISTRY_PATH handler_registry.yaml Registry file path

Trigger Types

Date Trigger (Run Once)

{
  "type": "date",
  "run_date": "2025-10-27T15:30:00"
}

Interval Trigger (Repeating)

{
  "type": "interval",
  "hours": 1,
  "minutes": 30
}

Cron Trigger (Schedule)

{
  "type": "cron",
  "hour": "*/2",
  "minute": "0"
}

πŸ§ͺ Testing

# Start server and handler in separate terminals, then:
poetry run python test_schedule.py

# Expected output:
# βœ“ Handlers listed successfully
# βœ“ Job executed immediately
# βœ“ Job scheduled for future execution

πŸ›£οΈ Roadmap

  • Authentication & authorization
  • Job execution history & logs
  • Advanced UI with charts & graphs
  • Docker containerization
  • Handler health monitoring
  • Job dependency management
  • Multi-instance clustering
  • Prometheus metrics export
  • WebSocket support for real-time updates

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

Built with these excellent libraries:


Made with ❀️ and Python

⬆ Back to Top

About

Uses python AppScheduler, ZeroRpc, and tornado to compose a simple cross-platform job scheduler server. Register your separate job executors then view and control scheduled jobs from one place.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published