# 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](https://ptpimg.me/9dlu9f.png)
See [demo.py](https://github.com/dongshuyan/function_controler/blob/main/demo.py) for details
# Reference
[Python控制函数运行时间](https://www.cnblogs.com/lyxdw/p/10033118.html)
Raw data
{
"_id": null,
"home_page": "https://github.com/dongshuyan/function_controler",
"name": "function-controler",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pip,function_controler,running time,control",
"author": "sauterne",
"author_email": "ssauterne@qq.com",
"download_url": "https://files.pythonhosted.org/packages/22/6b/d3aa0e0de467553afabfea6c0b1769006f4dde0a10b8749db802b4f4780a/function_controler-0.0.7.tar.gz",
"platform": "any",
"description": "# function_controler\nControl the maximum running time of a function.\n\n# parameters\n## func\nFunctions that are limited in runtime, type: function \n\u88ab\u9650\u5236\u8fd0\u884c\u65f6\u957f\u7684\u51fd\u6570, type: function \n## args\nParameters of func, type: tuple, defeat: args=() \n\u6b64\u51fd\u6570\u7684\u53c2\u6570, type: tuple, defeat:args=() \n## limit_time\nThe maximum execution time in seconds. If you set 0, there is no limit, type: float, defeat: limit_time=0 \n\u8bbe\u7f6e\u6700\u5927\u5141\u8bb8\u6267\u884c\u65f6\u957f,\u5355\u4f4d:\u79d2 \u5982\u679c\u8bbe\u7f6e0\u5219\u6ca1\u6709\u9650\u5236, type: float, defeat: limit_time=0 \n## kill\nWhether to stop the thread after the timeout, type: bool, defeat: kill=True \n\u8d85\u65f6\u4e4b\u540e\u662f\u5426\u7ed3\u675f\u7ebf\u7a0b, type: bool, defeat: kill=True \n## allow_log\nWhether to print the logs, type: bool, defeat: allow_log=False\n\u662f\u5426\u5141\u8bb8\u6253\u5370\u65e5\u5fd7,\u9ed8\u8ba4\u4e0d\u6253\u5370 type: bool, defeat: allow_log=False\n\n# Return\nReturn the return value of func,return None if timeout \n\u672a\u8d85\u65f6\u8fd4\u56de\u88ab\u88c5\u9970\u51fd\u6570\u8fd4\u56de\u503c,\u8d85\u65f6\u5219\u8fd4\u56de None \n\n# Useage\nfrom function_controler.func_ctrl import func_ctrl \nfunc_ctrl(func=FUNCTION_NAME,args=(ARGS),limit_time=LIMIT_TIME,kill=BOOL,allow_log=BOOL) \n![Img_Demo](https://ptpimg.me/9dlu9f.png)\n \nSee [demo.py](https://github.com/dongshuyan/function_controler/blob/main/demo.py) for details \n\n# Reference\n[Python\u63a7\u5236\u51fd\u6570\u8fd0\u884c\u65f6\u95f4](https://www.cnblogs.com/lyxdw/p/10033118.html)",
"bugtrack_url": null,
"license": "MIT Licence",
"summary": "Control the maximum running time of a function.",
"version": "0.0.7",
"project_urls": {
"Homepage": "https://github.com/dongshuyan/function_controler"
},
"split_keywords": [
"pip",
"function_controler",
"running time",
"control"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "226bd3aa0e0de467553afabfea6c0b1769006f4dde0a10b8749db802b4f4780a",
"md5": "01865427f96f0cd86f3a79e26ef9271a",
"sha256": "ea9753a80e1e4161a2fb020e2cf6515b2a5951251fbf947027e9109e9e49b601"
},
"downloads": -1,
"filename": "function_controler-0.0.7.tar.gz",
"has_sig": false,
"md5_digest": "01865427f96f0cd86f3a79e26ef9271a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3619,
"upload_time": "2022-08-03T14:18:21",
"upload_time_iso_8601": "2022-08-03T14:18:21.686803Z",
"url": "https://files.pythonhosted.org/packages/22/6b/d3aa0e0de467553afabfea6c0b1769006f4dde0a10b8749db802b4f4780a/function_controler-0.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-08-03 14:18:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "dongshuyan",
"github_project": "function_controler",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "function-controler"
}