Skip to main content

TaskLauncher

🛠️ 跨平台进程与 Python 脚本启动、监控与管理工具

TaskLauncher 是一个轻量级的 Python 包,支持在多平台下安全、灵活地启动和管理任意系统命令或 Python 脚本。它支持任务运行时资源监控、进程终止、参数传递、异常保护等特性,专为自动化和系统集成场景设计。


主要功能

  • 支持跨平台启动任意命令或 Python 脚本
  • 自动识别主机操作系统信息
  • 返回进程号、唯一任务标识(tag)及启动信息
  • 实时获取进程资源占用、状态与运行时间
  • 支持进程中止、强制杀死
  • 支持参数化执行
  • 失败时不会影响主进程或系统
  • Python 脚本专属执行接口(自动格式化参数)
  • 易于集成与扩展

安装

pip install tasklauncher

或从源码安装:

git clone https://github.com/yourgithub/TaskLauncher.git
cd TaskLauncher
pip install .

快速上手

启动任意命令

from tasklauncher.core import TaskLauncher

launcher = TaskLauncher()
result = launcher.run_command('ls' if launcher.system_info['system'] != 'Windows' else 'dir', shell=True)
print(result)

启动 Python 脚本(自动参数格式化)

info = launcher.run_python('example.py', 'arg1', 42)
print(info)

查询任务状态与资源

tag = info['tag']
status = launcher.task_status(tag)
print(status)

等待任务结束并获取输出

result = launcher.wait_task(tag)
print(result)

停止/强杀任务

launcher.stop_task(tag)      # 优雅终止
launcher.stop_task(tag, force=True)  # 强制杀死

API 参考

TaskLauncher 类

方法 说明
run_command(cmd, ...) 启动任意命令,返回tag、pid等
run_python(pyfile, *args, python_executable, ...) 启动Python脚本
stop_task(tag, force=False) 停止(或强制终止)任务
task_status(tag) 获取任务运行状态及资源情况
wait_task(tag, timeout=None) 等待任务结束,获取输出

详见代码注释或文档。


测试

  1. 在 tests/ 目录中加入 example.py:

    print("Hello, World!")
    
  2. 运行测试:

    pip install pytest
    pytest tests/
    

如何贡献

  1. Fork 本项目并创建分支
  2. 提交 PR(合并请求)前请确保单元测试通过
  3. 欢迎修复bug、新增特性或优化文档

License

MIT License


联系

如有建议、需求或 bug,欢迎 issue 或 PR!

Metadata

Release files for TaskLauncher 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TaskLauncher 0.1.0
File Size Uploaded Provenance Actions
TaskLauncher-0.1.0.tar.gz 5.1 kB Without provenance Details for TaskLauncher-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for TaskLauncher 0.1.0
File Interpreter ABI Platform Actions
TaskLauncher-0.1.0-py3-none-any.whl Python 3 none any Details for TaskLauncher-0.1.0-py3-none-any.whl

Total release size: 11.5 kB

Release files / TaskLauncher-0.1.0.tar.gz

Download URL TaskLauncher-0.1.0.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e73b08122dd6aea19f76c61b9b64110424bca2b957cafe3ac6632e9eb8316d1b
BLAKE2b-256 checksum
How to use checksums
31db9dee3247b69346b1a5d945e277ef78b51b49faaa4273d985a39c495e35eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.0

Release files / TaskLauncher-0.1.0-py3-none-any.whl

Download URL TaskLauncher-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69d65c5f22ec5dd05c8f3c9367387efe295fe3be5f88c84bb3d41939e1f0c044
BLAKE2b-256 checksum
How to use checksums
89568f41e59d226186fea4a0b581aa8ccb71830c2a69130da63b48b0f7cbfc64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.0

Security for TaskLauncher 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page