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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: retryer-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 7fd45a515f4c24010d064b7c7ebb5370e32137590d4dc90166d8882408833db8
MD5 2c7f7127152be678d92b90f3060a52c5
BLAKE2b-256 520a46262ba70e2b9e7c9f0a59456fbabe1e34660376a81bac1b15bb3abb14d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: retryer-1.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7e8921d9142d5c3a0b4bf69d041c2506e206f15280997f96172875768ba5de26
MD5 1b7b4d4a05af0f222644c4c5800de215
BLAKE2b-256 04d1b427a872eaad0ecfbaf2727e0e3290686db83da604612f385a4c50f3e0dc

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