Skip to main content

timeout decorator for python

Project description

th-timeoutdecorator

简介

th-timeoutdecorator 是一个用于Python的超时修饰器,目前已在 Windows 和 Linux 下测试过,也经过了异步兼容的测试,目前只是基本实现了要达到的目的。

修改自这份 原代码 不过它无法正常使用。

Why

实际上超时修饰有很多,但大多数都有很多问题,一部分只能运行在 Linux 系统上,还有一部分无法异步兼容,使得无法满足我的另一个项目 XUN_Bot 的需求,直到我找到了这份 原代码,令人非常惊艳的code,但是由于部分原因使得它无法被正常使用。而本项目是我修改后可以正常使用的版本。

安装

From source code:

python setup.py install

From pypi:

pip install timeoutdecorator

使用方法

import time
import timeoutdecorator

@timeoutdecorator.timeout(4)
def testmain():
    print("Start")
    for i in range(6):
        time.sleep()
        print("[Test] {} seconds have passed".format(i+1))

def mytest():
    try:
        testmain()
    except TimeoutException as e:
        print("[Test] {}".format(e))

if __name__ == '__main__':
    mytest()

开源许可证

本项目使用 MIT 许可证。

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

kth-timeoutdecorator-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

kth_timeoutdecorator-0.0.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file kth-timeoutdecorator-0.0.2.tar.gz.

File metadata

  • Download URL: kth-timeoutdecorator-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for kth-timeoutdecorator-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5197c813bfce3b7e867997bdd44d6ab03bed8bb85f178defa18192b22a83368d
MD5 871b9d57f569458d7dec9a65fd93651e
BLAKE2b-256 eb3685cf4599ed6a72fc3d4b18f4fa7e5f6d6a0e7be3aed12c3da4fab3286044

See more details on using hashes here.

File details

Details for the file kth_timeoutdecorator-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: kth_timeoutdecorator-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for kth_timeoutdecorator-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e61bcda391e380e841e48c0fac469b8267ff344c86ab30aacee515c7c6238e8
MD5 cfc4b328644dd6ee7520bd1df6161894
BLAKE2b-256 f7828d948725d214e3645e877dbce159bcb6bf7b8cc100d732e1addb51909d26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page