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

Uploaded Source

Built Distribution

leopy666-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for leopy666-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2482576160199ab0e0842733165e444d444f43d4c98e7704224f52792493e250
MD5 f85753642c7b7292c78aba3e918009e7
BLAKE2b-256 009c54a85d71a38ce43b27141d14ac05ef8188946a606ee1245131b0a6719169

See more details on using hashes here.

File details

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

File metadata

  • Download URL: leopy666-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6c584b4d251bbf052924d871eade4db073fc263bf6fda30ed120d2083c59ee7
MD5 7f52aaef15d9741218e9a38d8042d232
BLAKE2b-256 f14b721da9a940964ad2e5b3262d452796d7f263ee706314352bdd3cb4ec1382

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