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

Uploaded Source

Built Distribution

leopy666-0.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for leopy666-0.2.0.tar.gz
Algorithm Hash digest
SHA256 50211901a751525f36e4e04d14c4bda0967f84c52b78abd867024f88c8bd330f
MD5 89c9455e1ca4dfb60ca383fb605d0934
BLAKE2b-256 67d523c244539a2e928e1f557df6272abd5e9d777a9588d8d15c51954a458d89

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for leopy666-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f96969f6c4fbce4c7075587a54d8c69f1ae4c2cdf77f0531d4d1511b6b2f1b0c
MD5 bcf393c659649671e500afc6cd550d7e
BLAKE2b-256 75921aea93c14fae368cfcf133c3f1d62af91d432eb42e9707b740ddc07784f9

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