kth-timeoutdecorator
简介
kth-timeoutdecorator 是一个用于Python的超时修饰器,目前已在 Windows 和 Linux 下测试过,也经过了异步兼容的测试,目前只是基本实现了要达到的目的。
修改自这份 原代码 不过它无法正常使用。
Why
实际上超时修饰有很多,但大多数都有很多问题,一部分只能运行在 Linux 系统上,还有一部分无法异步兼容,使得无法满足我的另一个项目 XUN_Bot 的需求,直到我找到了这份 原代码,令人非常惊艳的code,但是由于部分原因使得它无法被正常使用。而本项目是我修改后可以正常使用的版本。
安装
From source code:
python setup.py install
From pypi:
pip install kth-timeoutdecorator
使用方法
import time
from kth_timeoutdecorator import *
@timeout(4)
def testmain():
print("Start")
for i in range(6):
time.sleep(1)
print("[Test] {} seconds have passed".format(i+1))
def mytest():
try:
testmain()
except TimeoutException as e:
print("[Test] {}".format(e))
if __name__ == '__main__':
mytest()
如果执行成功,则会输出以下信息:
[Test] 1 seconds have passed
[Test] 2 seconds have passed
[Test] 3 seconds have passed
[Test] function run too long, time limit exceeded.
开源许可证
本项目使用 MIT 许可证。
开发日志
0.0.4
- 修改了
seconds参数的可选项,使得修饰器更加灵活。
0.0.5
- 修复了之前版本的bug,请勿再使用0.0.2版本
Metadata
Release files for kth-timeoutdecorator 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kth-timeoutdecorator-0.0.5.tar.gz | 3.5 kB | Without provenance | Details for kth-timeoutdecorator-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kth_timeoutdecorator-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for kth_timeoutdecorator-0.0.5-py3-none-any.whl |
Total release size: 8.4 kB
Release files / kth-timeoutdecorator-0.0.5.tar.gz
| Download URL | kth-timeoutdecorator-0.0.5.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8b1e763232414c482fe8bc43c3678726a8fbacebd8d1e8e523579bacc4806858
|
|
BLAKE2b-256 checksum How to use checksums |
67b3b37ff010f71cef0f199332c857dfd599922646a71c868479d3b021174141
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / kth_timeoutdecorator-0.0.5-py3-none-any.whl
| Download URL | kth_timeoutdecorator-0.0.5-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5cf52acbdfb5606035d29b4e276876f73854f37ed076a266de8689225b4ea654
|
|
BLAKE2b-256 checksum How to use checksums |
155f522a8cc5c92d747d40066da9362fe86d3188e1c80e7019454694ecd86345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for kth-timeoutdecorator 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.