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 retryer

# Usage

from retryr import retryer

# Define your custom_action function
def custom_action(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.

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: retryer-1.0.4.tar.gz
  • Upload date:
  • Size: 2.7 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.4.tar.gz
Algorithm Hash digest
SHA256 4f7fa31202818168f57c79afe476373e2bee2f044fce5f1f0f3188f70f1c4222
MD5 38a32ce28fd06d9f217b3082a4079b39
BLAKE2b-256 ac1ed36f0f919870de138dbad519a8a5706c41409b96ba6d4ca0f39478d69999

See more details on using hashes here.

File details

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

File metadata

  • Download URL: retryer-1.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cf3f81036553b6da4b8336f009f53cdadd7f4a89c44f971ba33a50f5069bab9a
MD5 42456f331894699984077d3fb33addcf
BLAKE2b-256 14640dde2ea482dfb54c7387d54002bcd19d7ed4c24f801d186a5549de5c9009

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