Skip to main content

A retry decorator for error handling

Project description

Retryer

PyPI version

A Python decorator that allows you to retry a function, and customise the action if it runs into error.

Installation

You can install this package using pip:

pip install retryer

# Usage

from retryer import retryer

# Define your custom on_error function
def custom_on_error(exception):

    print(f"Custom error handling: {exception}")
    # You can perform any action you want here

@retryer(max_retries=5, retry_delay=2, on_error=custom_action)
def your_function():
    # Your code here
    # If this function raises an error, it will retry up to 5 times with a 2-second delay.

if __name__ == "__main__":
    your_function()

Parameters

  • max_retries: The maximum number of times the function should be retried on error.
  • retry_delay: The delay in seconds between retry attempts.
  • on_error: A custom error handling function that will be executed when an error occurs.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

If you have any questions, feel free to contact me at vishwanathkannan23@gmail.com

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

retryer-1.0.1.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

retryer-1.0.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file retryer-1.0.1.tar.gz.

File metadata

  • Download URL: retryer-1.0.1.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for retryer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3713ffb3cea8a84858bcbba44d6e61d59444c2471711191318389fe9b5918e23
MD5 2d88cd51fd3d75d14e6ed016d93bf748
BLAKE2b-256 c7f83bc1f5d8c9ac4a442bef99626788234b0868b21d10b26be4d92ccd52c0c8

See more details on using hashes here.

File details

Details for the file retryer-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: retryer-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.7

File hashes

Hashes for retryer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98935f254a9e86d9b2e878646834947d920e2bd28a8085896569532c37bb22c0
MD5 8ca88dd3d772ee1c36ef7a864e2a7947
BLAKE2b-256 fb528980e49d654d4666333ee05203631fef5b09b4f687c502bc14ba6eaed666

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page