Retry Decorator
Project description
Usage
Retry decorator
#!/usr/bin/env python from __future__ import print_function import sys from retry_decorator import retry def throw_err(msg): print('hello', file=sys.stderr) raise Exception('throwing err for {}'.format(msg)) def callback(msg): print('callback called: {}'.format(msg), file=sys.stderr) @retry(Exception, tries=3, timeout_secs=0.1) def test_retry_via_decorator(): throw_err('retry-via-deco') def test_retry_via_instance(): cbe = { Exception: lambda: callback('retry-via-instance') } retry(tries=3, callback_by_exception=cbe)(throw_err)('retry-via-instance') if __name__ == '__main__': try: test_retry_via_decorator() except Exception as e: print('Received the last exception') try: test_retry_via_instance() except Exception as e: print('Received the last exception')
Credits
This project is a fork of upstream https://github.com/pnpnpn/retry-decorator
Contribute
Best contribute to [upstream](https://github.com/pnpnpn/retry-decorator) project, but it _might_ be abandoned. Also its defaults will be different from this project, unless [PR21](https://github.com/pnpnpn/retry-decorator/pull/21) (which is the reason for this fork) is accepted.
So… it’s up to you which project you raise your PR against, but contributions are welcome.
See also
[PyRetry](https://github.com/Abeautifulsnow/PyRetry)
[retry_module](https://github.com/adityaprakash-bobby/retry_module)
[retry2](https://github.com/eSAMTrade/retry)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file retry-deco-0.0.1.tar.gz
.
File metadata
- Download URL: retry-deco-0.0.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a1c5baa2454423dc78f1497dede201818335227dbf0e88d48005feb4e6ce5d0 |
|
MD5 | 186b7d5fda4b4171a112e7d0a6bb4d92 |
|
BLAKE2b-256 | 0c5725c43910f5c5c75a266cea7d1638bacb11589a94b4cf4c801b485319b0d8 |