
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
This Python package provides decorators to handle exceptions, measure execution time, and set timeouts.
To install decoratorsutility, simply use pip:
pip install decoratorsutility
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!"
The Sphinx-generated documentation for PathUtils can be found here.
Feel free to contribute by submitting issues here.
FAQs
decorators utility
We found that decoratorsutility demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.