Skip to main content

Control the maximum running time of a function.

Project description

function_controler

Control the maximum running time of a function.

parameters

func

Functions that are limited in runtime, type: function
被限制运行时长的函数, type: function

args

Parameters of func, type: tuple, defeat: args=()
此函数的参数, type: tuple, defeat:args=()

limit_time

The maximum execution time in seconds. If you set 0, there is no limit, type: float, defeat: limit_time=0
设置最大允许执行时长,单位:秒 如果设置0则没有限制, type: float, defeat: limit_time=0

kill

Whether to stop the thread after the timeout, type: bool, defeat: kill=True
超时之后是否结束线程, type: bool, defeat: kill=True

allow_log

Whether to print the logs, type: bool, defeat: allow_log=True
是否允许打印日志, type: bool, defeat: allow_log=True

Return

Return the return value of func,return None if timeout
未超时返回被装饰函数返回值,超时则返回 None

Useage

from function_controler.func_ctrl import func_ctrl
func_ctrl(func=FUNCTION_NAME,args=(ARGS),limit_time=LIMIT_TIME,kill=BOOL,allow_log=BOOL)
Img_Demo

See demo.py for details

Reference

Python控制函数运行时间

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

function_controler-0.0.5.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file function_controler-0.0.5.tar.gz.

File metadata

  • Download URL: function_controler-0.0.5.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.0

File hashes

Hashes for function_controler-0.0.5.tar.gz
Algorithm Hash digest
SHA256 fdfd10f900bf3bb3b6b1d8e1d6c0fc0c29a87e9c191cca757b211a95bc8fb99e
MD5 da3a791c1c02641c8bc0e2aee2b54a34
BLAKE2b-256 4a3e3b5b51bd2f71ceefe5e20d5c276ad18dd70811b68aef6bcbd7a3992bf748

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