Skip to main content

A small CLI tool for reproducing heisenbugs

Project description

Heisenrun

Heisenrun is a small CLI tool for reproducing heisenbugs by running many instances of a command in parallel.

Heisenbugs are bugs that appear only under certain timing or concurrency conditions and disappear when you try to debug them. Heisenrun increases the chance of triggering such bugs by repeatedly executing a command concurrently.

Typical use cases:

  • Reproducing flaky tests
  • Triggering race conditions
  • Stress-testing CLI programs
  • Detecting nondeterministic behavior

Getting Started

Run instantly (recommended)

Using uv:

uv tool run heisenrun --help

Example:

uv tool run heisenrun -n 10 -m 2 -- sleep {#}

This downloads and installs heisenrun into an isolated environment. If you wish more control please consider the next command.

Install tool via UV (also recommended)

You can explicitly also heisenrun with uv:

uv tool install heisenrun

Then run:

heisenrun --help

The uv tool install command gives you more control. You can specify the tool's version, manually upgrade it, remove it, and etc.

Install with pipx

pipx also installs CLI tools in isolated environments:

pipx install heisenrun

Then run:

heisenrun --help

Install with pip (not recommended)

Global installation via pip works but is generally discouraged for CLI tools:

pip install heisenrun

Examples

Run a command 10 times

All 10 processes are created instantly. They run in parallel.

heisenrun -n 10 -- sleep 1

Use run index {#}

Use {#} in command to insert the index of the current run:

heisenrun -n 10 -- sleep {#}

Example expansion:

sleep 0
sleep 1
sleep 2
...
sleep 9

Limit parallelism

The -m option allows you to specify the maximum number of commands running in parallel. This will take about 5 seconds.

heisenrun -n 10 -m 2 -- sleep 1

Set timeouts

Abort runs that take too long:

heisenrun -n 10 -t 5s -- sleep {#}

Example report:

   Execution Report
┏━━━━━━━━━━┳━━━━━━━━━┓
┃ Instance ┃ Status  ┃
┡━━━━━━━━━━╇━━━━━━━━━┩
│        0 │ SUCCESS │
│        1 │ SUCCESS │
│        2 │ SUCCESS │
│        3 │ SUCCESS │
│        4 │ SUCCESS │
│        5 │ SUCCESS │
│        6 │ TIMEOUT │
│        7 │ TIMEOUT │
│        8 │ TIMEOUT │
│        9 │ TIMEOUT │
└──────────┴─────────┘

Capture outputs

Store outputs (stdout and stderr) of each run in a directory:

heisenrun -n 50 -o outputs -- ./program

Example directory structure:

outputs/
  0_output.txt
  1_output.txt
  ...

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

heisenrun-0.0.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

heisenrun-0.0.4-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file heisenrun-0.0.4.tar.gz.

File metadata

  • Download URL: heisenrun-0.0.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for heisenrun-0.0.4.tar.gz
Algorithm Hash digest
SHA256 1cd09025ef7a49f63bc6dda510da8bbb0f8764a001dc4559cac8aff68aaa281a
MD5 6c65fd3af5f6b76e2f1dab6c97579c23
BLAKE2b-256 4a8c8ba14757b07cc3bcf05716586ddd7654170ce0249a8a3006488f2c14c2a2

See more details on using hashes here.

File details

Details for the file heisenrun-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: heisenrun-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for heisenrun-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3edf6a5be7bf61e04f442bec825f1c4ebdf0f31d935136c6f6c2588a732884cf
MD5 3e73d6b2cde8588d3ce042309ca6ebde
BLAKE2b-256 dcf073f3c6c8ac9bffae27561f4e8a5a80b1b187ffca2a9093162b9c92521db4

See more details on using hashes here.

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