Skip to main content

Python tools developed by Leo.

Project description

leopy

Python tools developed by Leo.

Decorators

  • timeout: This decorator can be used to set a timeout for a function. It takes a parameter seconds, which represents the maximum allowed execution time of the function in seconds. If the function execution time exceeds the specified timeout, the decorator raises a TimeoutError exception.

  • rate_limiter: This decorator can be used to limit the call frequency of a function. It takes two parameters: limit, which represents the maximum number of allowed calls within a specified time interval, and interval, which represents the length of the time interval in seconds. If the function is called too frequently, the decorator automatically introduces a delay to meet the rate limiting requirement.

  • stoppable: This decorator can convert a function into a stoppable background thread. It takes an optional parameter sleep_time, which specifies the sleep time between each function execution, defaulting to 1 second. The decorator internally creates a thread event object stop_event to control the stopping of the thread. In a separate thread, the original function is continuously executed in a loop, sleeping according to sleep_time after each execution. By calling the stop function returned by the decorator, the thread execution can be stopped at any time. This decorator is very useful in situations where long-running tasks or dynamic control of task execution is needed.

  • timer: This decorator can be used to measure the execution time of a function. It records the start time of the function execution and then calculates and prints the execution time after the function completes.

  • cache: This decorator can be used to cache the results of a function. If the function has been called with the same arguments before, the decorator directly returns the cached result instead of re-executing the function. This can improve the performance of functions, especially for computationally expensive functions that are frequently called with the same arguments.

  • retry_decorator: This decorator can be used to handle exceptions that may occur during function execution. If the function raises an exception, the decorator automatically retries the function execution until the specified maximum number of retries is reached. There is a certain delay time between each retry.

  • logger: This decorator can be used to log the call information and return value of a function. It prints the function name, arguments, and other information before the function executes, and prints the return value of the function after it executes. This is very helpful for debugging and tracing the function execution process.

Utils

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

leopy666-0.3.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

leopy666-0.3.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file leopy666-0.3.0.tar.gz.

File metadata

  • Download URL: leopy666-0.3.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for leopy666-0.3.0.tar.gz
Algorithm Hash digest
SHA256 554da7e20f37703f9d4a20c54f3aa4ba7b49c5e8fc0d8ed28b27759696ae8612
MD5 1bbe351af932f2bc9804afaaf4fc7ae8
BLAKE2b-256 1185dfeef3e9eb01dbe95929d2fb67ea50da05b82b19418d9c53f71fd1616ee0

See more details on using hashes here.

File details

Details for the file leopy666-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: leopy666-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for leopy666-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef4b25484af01930f1bef6a2b3d5ade45c821adb69467f229f0db4f55ab1c291
MD5 0b1b8ad2d1d831f41ce915700f5640e1
BLAKE2b-256 9e3399846a83185990b3cdd04a8c8b5d3afc1b9bb6437aced113bccf77d98c85

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