Skip to main content

decoratorsutility

Introduction

This Python package provides decorators to handle exceptions, measure execution time, and set timeouts.

Installation

To install decoratorsutility, simply use pip:

pip install decoratorsutility

Usage Example

exception_dec

Decorator to handle exceptions by logging errors to a specified file path.

@exception_dec('module_name', '/path/to/logfile.log')
def function_name(*args, **kwargs):
    try:
        # Function execution
        return func(*args, **kwargs)
    except Exception as err:
        # Logs the error to the specified file path
        log_error(module=exc_mod, file_path=exc_path, error=err)
        logging.error(err)

repeat_on_error

Decorator to retry function execution a set number of times in case of exceptions.

@repeat_on_error(max_try=3, error_log='log/logfile.log', show_error=True)
def test_dummy(arg1:int):
    return arg1/0

timeout_decorator

Decorator to set a timeout for a function.

from decoratorsutility.decorators import timeout_decorator

@timeout_decorator(timeout=5)
def my_function():
    time.sleep(6)  # Simulate a long-running function
    return "Success!"

Documentation

The Sphinx-generated documentation for PathUtils can be found here.

Contribution

Feel free to contribute by submitting issues here.

Metadata

Release files for decoratorsutility 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for decoratorsutility 1.0.0
File Interpreter ABI Platform Actions
decoratorsutility-1.0.0-py3-none-any.whl Python 3 none any Details for decoratorsutility-1.0.0-py3-none-any.whl

Release files / decoratorsutility-1.0.0-py3-none-any.whl

Download URL decoratorsutility-1.0.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d90a422dd95947929f9c7b31e965c45c429e1bfea6e78cf627ab4c34f17499a
BLAKE2b-256 checksum
How to use checksums
c6ca478011e8ed35edc5cf3bf2bf232d0c261dcf22839c885532d90f43e25f45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.0

Security for decoratorsutility 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page