Skip to main content

⏰ Process Time Killer

process-time-killer is a Python utility to run subprocesses and terminate them after a specified timeout. This package helps in controlling processes by running commands for a limited time and ensuring they are terminated gracefully or forcefully.

Features

  • Run any subprocess for a specified duration.
  • Automatically terminate the subprocess after a given timeout.
  • Graceful termination or forced killing if the process does not exit on time.
  • Logs all steps, including the start, termination attempt, and any errors.

Installation

You can install process-time-killer via pip:

pip install process-time-killer

Usage

Command-line Interface (CLI)

Run the utility from the command line by specifying the command and an optional timeout:

timekiller "ping google.com" --timeout 10

Arguments:

  • command: The command to run in the subprocess (default: "ping google.com").
  • --timeout: Time in seconds before the subprocess is terminated (default: 12 seconds).

Example:

Run the echo command for 5 seconds:

timekiller "echo Hello World" --timeout 5

Programmatic Usage

You can also use this utility in your Python code by calling the run_subprocess function:

from timekiller import run_subprocess

command = "echo Hello World"
timeout = 10

run_subprocess(command, timeout)

Functions

run_subprocess(command: str, seconds: int)

Runs a subprocess with the specified command and terminates it after the given number of seconds.

Arguments:

  • command (str): The command to execute in the subprocess.
  • seconds (int): Number of seconds to run the subprocess before terminating.

Raises:

  • ValueError: If the command or seconds parameter is invalid.
  • RuntimeError: If there is an issue with starting or terminating the subprocess.

main()

The main function that serves as the entry point for the command-line interface (CLI). It parses the arguments and calls run_subprocess.

Logging

This package uses Python’s built-in logging module to log: • The start of the subprocess. • The attempt to terminate the subprocess after the timeout. • Any errors that occur during execution.

License

This project is licensed under the MIT License.

Metadata

Release files for process-time-killer 0.2

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

Source distribution (sdist)

Source distribution for process-time-killer 0.2
File Size Uploaded Provenance Actions
process_time_killer-0.2.tar.gz 2.9 kB Without provenance Details for process_time_killer-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for process-time-killer 0.2
File Interpreter ABI Platform Actions
process_time_killer-0.2-py3-none-any.whl Python 3 none any Details for process_time_killer-0.2-py3-none-any.whl

Total release size: 6.7 kB

Release files / process_time_killer-0.2.tar.gz

Download URL process_time_killer-0.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3630ce9e7ae57021afc056d7dcdef15d59e43efee604e5a9d882da688236451d
BLAKE2b-256 checksum
How to use checksums
cb6d79c67348023ca8dc5bb0338f1dc44639af6bce0f1d47a68d6507f5bc68a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.11

Release files / process_time_killer-0.2-py3-none-any.whl

Download URL process_time_killer-0.2-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e99a2b27765722037b79c7435f7e3e667540294c4c3eda6b06f4eb489920120
BLAKE2b-256 checksum
How to use checksums
9e178a78c1c1c2702be33eb362249c89ffb0bc71629106de85d4b2403a9761e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.11

Security for process-time-killer 0.2

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.

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