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.0)
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.0)
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.1.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.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_simple_timeout_wrap-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 395ee35f71a6f3ad4dad090fdc0c1b8ed6b5ec7728477bcce4f413edbd8f2cd1
MD5 d4d838bcab82b195cd18c80174f17aa8
BLAKE2b-256 070b6a06eff752c474b2b00fe7f24ec04b00dc64a34685abb8c58f782a82ad50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_simple_timeout_wrap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 864f9414810cdfc9a749674b4a30a32cfa75e8dd9757160c0df146631c09f9bb
MD5 8e9bbf2b995b389d2d88ba52407be9ba
BLAKE2b-256 bd2ca6168176e685869cd70fc60f328ed3ca51ceba19a0e9d419c1ec3917efd2

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