Skip to main content

Lightweight command timeout utility with zero runtime dependencies

Project description

timeout-dead

PyPI version Python License Tests Ruff Pyright

Lightweight command timeout utility with zero runtime dependencies. Runs any shell command with a configurable time limit and termination signal. If the command exceeds the timeout, timeout-dead sends the chosen signal, waits a 1-second grace period, then force-kills the process. Works on Linux, macOS, and Windows (Git Bash / WSL).

Installation

pip install timeout-dead

Or via uv:

uv tool install timeout-dead

Requires Python 3.10 or later. Zero runtime dependencies — pure Python standard library.

Quick start

# Run a command with default 60s timeout
timeout-dead "python -c 'print(42)'"

# Short alias also works
time-d "echo hello"

# Specify a custom timeout
timeout-dead --sec 120 "npm run build"

# Use SIGINT instead of default SIGTERM
timeout-dead --signal INT --sec 30 "long-running-server"

# Run silently — suppress all normal output
timeout-dead --no-output "curl -s https://example.com"

Usage

usage: timeout-dead [-h] [-v] [--sec SECONDS] [--signal SIGNAL] [--no-output] COMMAND ...

Lightweight command timeout utility.

positional arguments:
  COMMAND               command to execute

options:
  -h, --help            show this help message and exit
  -v, --version         show version and exit
  --sec SECONDS         timeout in seconds (default: 60)
  --signal SIGNAL       signal to send on timeout (TERM, KILL, HUP, INT)
  --no-output           suppress normal output (stdout, stderr, header, footer)

How it works

  1. timeout-dead starts the command in a new process group (Unix) / console group (Windows).
  2. A background timer waits for the specified timeout.
  3. If the command finishes in time, its output and exit code are forwarded.
  4. If the timeout expires:
    • The chosen signal is sent to the process group.
    • After 1 second, if the process is still running, SIGKILL (Unix) or process.kill() (Windows) is sent.
    • A Timeout exceeded message is printed to stderr.

Signal reference

Signal Unix Windows
TERM SIGTERM (15) — terminate gracefully CTRL_BREAK_EVENT — console break
KILL SIGKILL (9) — force kill Falls back to TerminateProcess
HUP SIGHUP (1) — hangup Falls back to TerminateProcess
INT SIGINT (2) — interrupt (Ctrl+C) CTRL_C_EVENT — console interrupt

Development

git clone https://github.com/UmbrellaLeaf5/timeout-dead
cd timeout-dead
uv sync --extra dev
uv run pytest tests/ -v
uv run ruff check src/timeout_dead/ tests/
uv run ruff format --check .
uv run pyright src/timeout_dead/

License

Unlicense — public domain.

Timeout icons created by Those Icons - Flaticon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timeout_dead-0.1.2.tar.gz (70.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timeout_dead-0.1.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file timeout_dead-0.1.2.tar.gz.

File metadata

  • Download URL: timeout_dead-0.1.2.tar.gz
  • Upload date:
  • Size: 70.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for timeout_dead-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6fba36b5217531ed62d8ba5fa0c48fff852cedce0db9009258466e7db9260098
MD5 045d3d9c86cab3742e545fd5f1673c05
BLAKE2b-256 d3f80f4bc891caaed967845108abf70e3eddbbf19afe5d0ed94038f8491fad8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for timeout_dead-0.1.2.tar.gz:

Publisher: publish.yml on UmbrellaLeaf5/timeout-dead

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file timeout_dead-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: timeout_dead-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for timeout_dead-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 969a17b6e1db51bae01937b57e9cc5b2bb147f51373eb79636ccaf033d892464
MD5 b2704e4eb581a54a8d6dec2096cac72e
BLAKE2b-256 877ed653c9c9b0a974c444536e6ed63802bceed7fc92338ec8655367c9a9b7e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for timeout_dead-0.1.2-py3-none-any.whl:

Publisher: publish.yml on UmbrellaLeaf5/timeout-dead

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page