Retry a command with exponential backoff and jitter.
Project description
recur
This command-line tool runs a single command repeatedly until it succeeds or allowed attempts run out. It implements optional exponential backoff with configurable jitter.
It was inspired by retry-cli. I wanted to have something like it, but as a single-file script without the Node.js dependency. The result depends only on Python and its standard library.
The CLI options are modeled after the parameters of the retry
decorator, which Python programmers may know. However, I do not use the retry
package or its code. The jitter behavior is different from retry
. Jitter is applied starting with the first retry, not the second. I think this is what the user expects. A single-number jitter argument results in random jitter picked uniformly from between zero and that number every time.
Requirements
Python 3.8 or later.
Installation
The recommended way to install recur is from PyPI with pipx.
pipx install recur-command
# or
pip install --user recur-command
Usage
usage: recur [-h] [-V] [-b BACKOFF] [-d DELAY] [-j JITTER] [-m MAX] [-t TRIES]
[-v]
command ...
Retry a command with exponential backoff and jitter.
positional arguments:
command command to run
args arguments
options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-b BACKOFF, --backoff BACKOFF
multiplier applied to delay on every attempt (default:
1, no backoff)
-d DELAY, --delay DELAY
constant or initial exponential delay (seconds,
default: 0)
-j JITTER, --jitter JITTER
additional random delay (maximum seconds or "min,max"
seconds, default: "0,0")
-m MAX, --max-delay MAX
maximum delay (seconds, default: 86400)
-t TRIES, --tries TRIES
maximum number of attempts (negative for infinite,
default: 3)
-v, --verbose announce failures
License
MIT.
Alternatives
- retry (joshdk). Written in Go.
go install github.com/joshdk/retry@master
. - retry (kadwanev). Written in Bash.
- retry (minfrin). Written in C. Packaged in Debian and Ubuntu repositories.
sudo apt install retry
. - retry (timofurrer). Written in Rust.
cargo install retry-cmd
. - retry-cli. Written in JavaScript for Node.js.
npx retry-cli
.
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
Built Distribution
File details
Details for the file recur_command-0.1.0.tar.gz
.
File metadata
- Download URL: recur_command-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 PyPy/7.3.12 Linux/6.2.0-26-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94b9f4518a4ea939fa6d4443ab7e9e4bad3d1ac8091cfa91cb02ea5aac01631f |
|
MD5 | cc4a15758f88391331ee3bd5ee67002c |
|
BLAKE2b-256 | 5fda64df09aad9cc130c3032441e254392f1cea49d9f7e6fd15005bbc17100c4 |
File details
Details for the file recur_command-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: recur_command-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 PyPy/7.3.12 Linux/6.2.0-26-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d449f4619d66b335dcf4418bc64f4a2898028cd095cc9a78e81d7a6bfac8b24 |
|
MD5 | 3b75d6d11fd2dc58cf9be0c824b98dd8 |
|
BLAKE2b-256 | b19d36d12ebb4431364b563b7f0c90837395c57ba6ad2faea7205afb760a4f7e |