Skip to main content

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=False 是否允许打印日志,默认不打印 type: bool, defeat: allow_log=False

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控制函数运行时间

Metadata

Release files for function-controler 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for function-controler 0.0.7
File Size Uploaded
function_controler-0.0.7.tar.gz 3.6 kB Details

Release files / function_controler-0.0.7.tar.gz

Download URL function_controler-0.0.7.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ea9753a80e1e4161a2fb020e2cf6515b2a5951251fbf947027e9109e9e49b601
BLAKE2b-256 checksum
How to use checksums
226bd3aa0e0de467553afabfea6c0b1769006f4dde0a10b8749db802b4f4780a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.0

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page