A cron-style scheduler that turns functions from any package into scheduled jobs via config files.
Project description
gpscheduler
GPScheduler (General-Purpose Scheduler) is a cron-style Python scheduler that turns functions from any package into scheduled jobs via config files, configures startup arguments, and exposes a decorator to mark schedulable functions.
中文文档:README.zh.md
Features
- Config-driven cron jobs — declare schedules, callables, and call arguments in YAML config files; no timers hardcoded in application code.
- Package-agnostic — point a job at any importable function in any installed package, located by dotted path.
- Two decorators —
@scheduledmarks a function as schedulable;@worker_initbuilds an expensive object (DB connection, network client, …) once and reuses it across runs. - Thread and process executors — each job picks its own pool. Threads for I/O-bound work, processes for CPU-bound or isolated work.
- Scheduler-wide globals — shared config values (
db_url,api_key, …) injected into every job that asks for them. - Graceful, cross-platform shutdown —
Ctrl+Con Windows,SIGINT/SIGTERMon Linux, with a configurable shutdown timeout. - Fail-Early validation — invalid config fails loudly at load time, never silently at the first trigger.
- Embeddable — run standalone via the CLI, or embed it inside a host application.
Installation
pip install gpscheduler
For local development from a clone:
source .venv/Scripts/activate # Git Bash on Windows
pip install -e ".[dev]"
Quick start
-
Install gpscheduler (see Installation).
-
Write a package containing a
@scheduledfunction:# myjobs/hello.py from gpscheduler import scheduled @scheduled def greet(name: str, *, greeting: str = "Hello") -> None: print(f"{greeting}, {name}!")
-
Point a config folder at it:
# configs/scheduler.yaml cfg_class_name: GPSchedulerConfig configured_class_name: GPScheduler executor: thread packages: [myjobs]
# configs/jobs/hello.yaml cfg_class_name: GPJobConfig func: "myjobs.hello.greet" cron: "*/2 * * * * *" # every 2 seconds (6-segment, leading seconds field) args: ["world"] kwargs: greeting: "Hi"
The config folder also needs a
global_env.yaml(required by the underlying gpconfig loader) — an empty{}is fine. -
Run it:
gpscheduler run --config configs
Use
gpscheduler list-jobs --config configsfor a dry run that validates config and lists enabled jobs without starting anything.
See the Examples page in the docs
for a complete, annotated demo covering arguments, job_globals injection, worker_init
in both thread and process pools, and more.
Documentation
Full documentation is published at https://linnetcodes.github.io/gpscheduler/ (English / 简体中文).
License
MIT © LinnetCodes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpscheduler-0.1.0.tar.gz.
File metadata
- Download URL: gpscheduler-0.1.0.tar.gz
- Upload date:
- Size: 108.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72dc056b11b07a7dd4944347cce81a179c2013deae18baa51452c23f97dd2a4b
|
|
| MD5 |
20e851046c9b5c1ddcc236961ec50859
|
|
| BLAKE2b-256 |
c54c2a2ed28fff1227d2bd9a65e5c909b6b39c91baf9be9dc1521a290e16cce3
|
Provenance
The following attestation bundles were made for gpscheduler-0.1.0.tar.gz:
Publisher:
python-publish.yml on LinnetCodes/gpscheduler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gpscheduler-0.1.0.tar.gz -
Subject digest:
72dc056b11b07a7dd4944347cce81a179c2013deae18baa51452c23f97dd2a4b - Sigstore transparency entry: 2167548592
- Sigstore integration time:
-
Permalink:
LinnetCodes/gpscheduler@4fc43a1d9b7a1709876218492490fd452b4ddb61 -
Branch / Tag:
refs/tags/version-0.1.0 - Owner: https://github.com/LinnetCodes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4fc43a1d9b7a1709876218492490fd452b4ddb61 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gpscheduler-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gpscheduler-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f64ba8c71cd3942812c4840b78b2534e905d8c3cde87b9608dfd3b88d682cbd
|
|
| MD5 |
8aa94ad9e31ac2276a9b322eb0a06aa7
|
|
| BLAKE2b-256 |
fd722bbc685ac7bff1ae8223b93d15a6abae47bb897f690b9342b7c07e38d48f
|
Provenance
The following attestation bundles were made for gpscheduler-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on LinnetCodes/gpscheduler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gpscheduler-0.1.0-py3-none-any.whl -
Subject digest:
4f64ba8c71cd3942812c4840b78b2534e905d8c3cde87b9608dfd3b88d682cbd - Sigstore transparency entry: 2167548604
- Sigstore integration time:
-
Permalink:
LinnetCodes/gpscheduler@4fc43a1d9b7a1709876218492490fd452b4ddb61 -
Branch / Tag:
refs/tags/version-0.1.0 - Owner: https://github.com/LinnetCodes
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@4fc43a1d9b7a1709876218492490fd452b4ddb61 -
Trigger Event:
release
-
Statement type: