ktimeout
Description
add timeout to any function
Install
pip install ktimeout
# or
pip3 install ktimeout
Usage
# CHECK 'demo.py' FOR ALL EXAMPLES
from typing import Optional
import time
from ktimeout import timeout
def func_with_arguments(sleep_time: float, extra_print: Optional[str] = None):
while True:
time.sleep(sleep_time)
print('Sleeping', sleep_time, 'sec', extra_print or '')
def func():
func_with_arguments(0.5, extra_print='called from func()')
try:
timeout.run(func, 2)
except Exception as e:
print(e)
try:
timeout.run(
timeout.partial(func_with_arguments, 0.25, extra_print='extra'),
2
)
except Exception as e:
print(e)
try:
with timeout.timeout(1):
while True:
sleep_time = 0.25
time.sleep(sleep_time)
print('Sleeping', sleep_time, 'sec')
except Exception as e:
print(e)
Metadata
Release files for ktimeout 0.0.7
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 |
|---|---|---|---|---|
| ktimeout-0.0.7.tar.gz | 2.1 kB | Without provenance | Details for ktimeout-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ktimeout-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for ktimeout-0.0.7-py3-none-any.whl |
Total release size: 5.3 kB
Release files / ktimeout-0.0.7.tar.gz
| Download URL | ktimeout-0.0.7.tar.gz |
|---|---|
| Size | 2.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8a0d75b60837285153c00ad291e60d3f31f582d59d1c3f96f26e257a09faaed
|
|
BLAKE2b-256 checksum How to use checksums |
ded7aa5dce1f9e0f57a8d7460549d553cdda5af67ccb292f004e9fd72aa67bbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.7.6
|
Release files / ktimeout-0.0.7-py3-none-any.whl
| Download URL | ktimeout-0.0.7-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6fef369f61b1f7e29053d4e01d159ebd34a18022b956816d6e7ba21a86894a7
|
|
BLAKE2b-256 checksum How to use checksums |
298e66a2ac8b51ea4f53522c9604921f5569d2a8ae424b43ad955d22a023875b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.7.6
|
Security for ktimeout 0.0.7
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.