safesched
安全的资源感知任务调度器 — 自动监控 CPU/内存/磁盘 IO/GPU 显存,过载时暂停调度,永远不会把你的机器跑崩。
✨ 主要特性
- 🔍 自动资源监控:实时监控 CPU、内存、磁盘 IO 和 GPU 显存
- 🛡️ 智能过载保护:系统过载时自动暂停,避免宕机
- 🎯 GPU 自动选择:自动检测并选择最空闲的 GPU
- ♻️ 任务重试:失败任务自动重试,可配置重试次数
- 📊 并发管理:灵活配置并发任务数和超时时间
📦 安装
推荐方式(使用 pipx,全局隔离安装)
pipx install safesched
或使用 pip(在虚拟环境中)
python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows PowerShell
.\.venv\Scripts\Activate.ps1
# Windows CMD
.\.venv\Scripts\activate.bat
pip install safesched
🚀 快速开始
批量调度任务(从 stdin)
macOS / Linux:
cat tasks.txt | safesched python process.py {}
Windows PowerShell:
Get-Content tasks.txt | safesched python process.py {}
Windows CMD:
type tasks.txt | safesched python process.py {}
其中 tasks.txt 每行一个参数,{} 作为占位符被替换。
运行单个命令
自动选择最空闲的 GPU 并执行:
safesched python train_model.py
指定 GPU 并配置并发
cat tasks.txt | safesched -g 0,1 -j 8 -t 3600 python process.py {}
参数说明:
-g 0,1:指定 GPU 列表(默认自动检测)-j 8:最大并发任务数(默认 8×GPU 数 或 CPU 核心数 / 2)-t 3600:单个任务超时时间(秒,默认 1 小时)-r 3:失败重试次数(默认 2 次)-v:详细日志输出
更多例子
处理 10000 个视频文件,自动检测 GPU,并发 4 个任务,每个任务超时 30 分钟:
ls *.mp4 | safesched -j 4 -t 1800 python encode.py {}
使用 CPU 模式处理任务(无 GPU):
cat tasks.txt | safesched python lightweight_task.py {}
📝 许可证
MIT License - 详见 LICENSE 文件
👤 作者
- Misaka14766
- 📧 misaka14766@gmail.com
- 🔗 GitHub
💬 反馈与贡献
欢迎提交 Issue 和 Pull Request!如有任何问题或建议,请通过以下方式联系:
Made with ❤️ by Misaka14766
Metadata
Release files for safesched 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safesched-0.1.1.tar.gz | 10.0 kB | Without provenance | Details for safesched-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safesched-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for safesched-0.1.1-py3-none-any.whl |
Total release size: 20.0 kB
Release files / safesched-0.1.1.tar.gz
| Download URL | safesched-0.1.1.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a12e394270f4fe0eeeb1fa83638af4326e0dbe515d1cccdfc5823e0a0f639a65
|
|
BLAKE2b-256 checksum How to use checksums |
dc27be5b14151a8150901abb07930a0788cbf2b23936a38d8f1c53b7f4b8b030
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / safesched-0.1.1-py3-none-any.whl
| Download URL | safesched-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2409a125a630e774beda1fac7fd5c9f6ab3021d769a9aa99b667e45447765019
|
|
BLAKE2b-256 checksum How to use checksums |
15c2166dbe39c38a46697e1b98ba8f61def3e338273d12e21964cc5cdf6832c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for safesched 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.