Skip to main content

A simple function execution time limit tool based on `concurrent.futures`.

Project description

py_simple_timeout_wrap

A simple function execution time limit tool based on concurrent.futures.

Installation

pip install py_simple_timeout_wrap

Usage

from py_simple_timeout_wrap import time_limit
import time

# Set function max execution time to 1 second
@time_limit(1)
def task_1():
    time.sleep(0.5)
    return "task_1: done"

# Normal execution within time limit
print(task_1()) # Output: task_1: done

# Set function max execution time to 1 second
@time_limit(1)
def task_2():
    time.sleep(1.5)
    return "task_2: done"

# Exceed time limit, throw TimeoutError automatically
print(task_2()) # TimeoutError: function `task_2` time limit exceeded (1s)

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

py_simple_timeout_wrap-0.1.0.tar.gz (2.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_simple_timeout_wrap-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_simple_timeout_wrap-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.12 Windows/11

File hashes

Hashes for py_simple_timeout_wrap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f299044f4d24994c1fb8fd5cfd50fc6a9e151e6fbffb3c60ebd79a93b0ff4bf1
MD5 bb17b65a41759cbe85ad0d94a8e75c3d
BLAKE2b-256 6546fda1f6ed567cddf41e2ae0ca0da9419a237847e51d27f77e20b3b665e4f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_simple_timeout_wrap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1d2e4c020c6ae8be232c01733ff46e9e3b70a2f6f36e89da5952abe5ba50902
MD5 bcc2d9ed7a519402c5cd30f4320490f1
BLAKE2b-256 11c81abcb93e24e5b7edf16fe07f70313a89fa07e4afcc6b4010a7d47e5967f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page