retimer
A simple package to make retry loops easier
Getting started
You can get retimer from PyPI,
which means it's easily installable with pip:
python -m pip install retimer
Example usage
Think of a scenario where you need to keep trying to do something for a range of time, usually you can write this:
from time import perfcounter
timeout = 10
begin = perfcounter()
while percounter() - begin < timeout:
# do something for 10 seconds
if retry_doing_something:
time.sleep(.5)
continue
if something_bad:
break
# all good
break
if perfcounter - begin >= timeout:
print(f"Could not do something after {timeout} seconds")
else:
print("Success!")
Rewriting using this package becomes:
from retimer import Timer
import time
timer = Timer(10)
while timer.not_expired:
# do something for 10 seconds
if retry_doing_something:
time.sleep(.5)
continue
if something_bad:
timer.explode()
# all good
break
if timer.expired:
print(f"Could not do something after {timer.duration} seconds")
else:
print("Success!")
Although both codes accomplish the same result, I personally find the second one more readable and shines when I need two or more chained loops
Changelog
Refer to the CHANGELOG.md file.
Metadata
Release files for retimer 0.1.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| retimer-0.1.0.9.tar.gz | 3.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| retimer-0.1.0.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / retimer-0.1.0.9.tar.gz
| Download URL | retimer-0.1.0.9.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
82d500849f54e081cf5917097a19d97dcc8ff90552bdc981ec3c8aeb210031cb
|
|
BLAKE2b-256 checksum How to use checksums |
2d175078a3914f3211e235a4c545423d05092342902590ecf251c205a766863b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure
|
Release files / retimer-0.1.0.9-py3-none-any.whl
| Download URL | retimer-0.1.0.9-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f9465b9a99a68e453e028559081b0f2bd935317e49423d58e02f8ab86ba487d
|
|
BLAKE2b-256 checksum How to use checksums |
edce65e8f639f1ba65d5a8e0997a5b57e726355a743e7b6d89ee863424261d80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.11.1 Linux/5.15.0-1024-azure
|
Security for retimer 0.1.0.9
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.