KaioRetry
KaioRetry is (yet another) retry decorator implementation, which is clearly inspired by the original retry module and is actually backward compatible with it.
Basic usage
Transparently perform retries on failures:
from kaioretry import retry, aioretry
@retry(exceptions=ValueError, tries=2)
def some_func(...):
...
@aioretry(exceptions=(ValueError, SomeOtherError), tries=-1, delay=1)
async def some_coroutine(...):
...
Documentation
If you care to read more, a more lengthy documentation is available on readthedocs.
Known Issues
Pylint
Pylint, it seems, is not really good a detecting decorators that change function signatures, and kaioretry defines and uses a lot of decorators (relatively speaking).
This means that such basic code:
from kaioretry import aioretry
@aioretry(exceptions=ZeroDivisionError)
async def func(x, y):
return x / y
Will trigger the following pylint errors:
E1120: No value for argument 'retry_obj' in function call (no-value-for-parameter)
According to pylint documentation, the only way to widely work around this
issue is to use the
signature-mutators
feature of pylint. This can be done either on the command line:
pylint --signature-mutators=kaioretry._make_decorator
Or through pylint configuration file:
# The TYPECHECK section accepts a signature-mutators directive.
[TYPECHECK]
# List of decorators that change the signature of a decorated function.
signature-mutators=kaioretry._make_decorator
(Of course, you can inline a # pylint: disable=no-value-for-parameter
comment on all aioretry() and retry() call lines, and it can be good
enough to disable a one-time warning, but repeating that line can be
tedious. The signature-mutators directive will globally disable the
signature-checking for aioretry() and retry() calls, so this can be easier
depending of your own usage of kaioretry.)
Mypy and functions generated by kaioretry.aioretry
Mypy may incorrectly infer the type of an
aioretry-decorated function as def (*Any, **Any) -> Any if the original
function:
- is a coroutine and
- has a returned type hinted as
Anyand/or if parameters are hinted asAny.
If the original function is fully annotated as non-Any, the resulting
decorated function annotations should be correctly inferred (according to
kaioretry
test).
It is unclear to me right now, if the kaioretry.aioretry function type hints
are incorrect or if it is an issue with either mypy or cpython. Or both. Or
all 3. Go figure.
Any information on that matter would be greatly appreciated. I've spent weeks trying to track down this issue. And while walking down this path has allowed me to fix some other (rather unrelated) type-hinting boo-boos from my part, this very specific issue is still puzzling me.
Feedback welcome.
Always.
Metadata
Release files for kaioretry 1.2.1
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 | |
|---|---|---|---|---|
| kaioretry-1.2.1.tar.gz | 21.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kaioretry-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.8 kB
Release files / kaioretry-1.2.1.tar.gz
| Download URL | kaioretry-1.2.1.tar.gz |
|---|---|
| Size | 21.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97a13099bdab3b7a25d2100055e382ec01c8f4da53fba11d7aa76c92c1a82481
|
|
BLAKE2b-256 checksum How to use checksums |
047febbeb45bec1288399cfa29ce604c8062388bf97e6218c9ea76b73e43ac44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.7 Linux/6.15.8-200.fc42.x86_64
|
Release files / kaioretry-1.2.1-py3-none-any.whl
| Download URL | kaioretry-1.2.1-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7d1f4dc31631cff3f63008c7c927f58208d8fdc2f432b136d03277a66cec84b
|
|
BLAKE2b-256 checksum How to use checksums |
3276ff33dd9da0439e407c80e2c9da0c4bccabd347233c69f0becdc4da56b294
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.7 Linux/6.15.8-200.fc42.x86_64
|
Security for kaioretry 1.2.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.