https://github.com/stsquad/retry
A wrapper for retrying failing functions, originally for running rsync on dodgy links
https://github.com/stsquad/retry
Last synced: 11 months ago
JSON representation
A wrapper for retrying failing functions, originally for running rsync on dodgy links
- Host: GitHub
- URL: https://github.com/stsquad/retry
- Owner: stsquad
- Created: 2013-02-05T16:06:45.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-06-06T12:32:31.000Z (about 2 years ago)
- Last Synced: 2025-06-07T02:04:56.989Z (about 1 year ago)
- Language: Python
- Homepage:
- Size: 44.9 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
retry.py
========
A simple wrapper script to keep retrying until a success/fail condition.
I originally wrote this as a simple wrapper script that monitored the return
code from rsync and retried the sync if it was non-zero (i.e. failed to complete).
This is useful if you have a very dodgy link which occasionally goes down causing
the current rsync session to bail-out.
I have since decided it is much more useful as a general purpose retry wrapper so
I've made it a lot more generic. The original behaviour can be run by:
retry.py -v -- rsync user@host:path/ .
Collecting Benchmarks
---------------------
Using -n and -c you can run something a number of times and collect a
benchmark for fast something runs with what pattern of error codes.
For example:
retry.py -n 5 -c -- ./random.sh
Gives:
Results summary:
0: 2 times (40.00%), avg time 0.019361 (0.000018 deviation)
3: 1 times (20.00%), avg time 0.025896 (0.000000 deviation)
4: 2 times (40.00%), avg time 0.011978 (0.000092 deviation)
Other Features
--------------
I've added the -c/--count option for use in testing situations. If you
have a program that fails occasionally you can run -n iterations and
get a summary of the return codes at the end of your run.
Ideally your test program should return different error codes for
different failure cases.