A signal based timeout context manager
Project description
A signal based timeout context manager and decorator.
Since it is signal based this package can not work under Windows operating system.
Usage
As a context manager:
import sys
from time import sleep
from timeoutcontext import timeout, TimeoutError
if sys.version_info < (3, 3):
from timeoutcontext._timeout import TimeoutError
try:
with timeout(1):
sleep(2)
except TimeoutError:
print('timeout')
As a decorator:
import sys
from time import sleep
from timeoutcontext import timeout, TimeoutError
if sys.version_info < (3, 3):
from timeoutcontext._timeout import TimeoutError
@timeout(1)
def wait():
sleep(2)
try:
wait()
except TimeoutError:
print('timeout')
License
Free software: BSD license
History
1.1.0 (2016-09-05)
Add the “Not working on Windows operating system” notice
Rename TimeoutException to TimeoutError
1.0.0 (2016-01-23)
First release on PyPI.
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
timeoutcontext-1.1.0.tar.gz
(12.8 kB
view hashes)
Built Distribution
Close
Hashes for timeoutcontext-1.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0393824ece044109ee50dd9229e819a6004c98bf38656ff052e517fa96287dd |
|
MD5 | 916cbf46b4d4394b2981243125aa9392 |
|
BLAKE2b-256 | 414c11cb21cfd548fb15884cc7d77424c6300180ad2b5efb945324d125a6bd75 |