Skip to main content

A retry decorator for error handling

Project description

Retryr

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 retryr

# Usage

from retryr import retryr

# Define your custom_action function
def custom_action(exception):

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

@retryr(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.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: retryer-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 801a50896ab03cc436777e98306d4e489e98e6bddeab1c858b1cbe8a202ee428
MD5 79f76ecce793c69c1461ae9a5f6f6755
BLAKE2b-256 3e741c9081c0b6685704241cacf71366e0f8dcd36b9c5d6583b3f0de293e85f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: retryer-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 70b64997f467b38c3b93be6bb7095f575a87ec0d03cd2eddad512c7db951bb3b
MD5 e9efd3bd1490ad1fbdb634ac6d7b343e
BLAKE2b-256 21c625e9899a2190be01f4f4fa234b65c0dbb6b2261f56d2119b778f0fa3c1c8

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