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
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
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.1 (2016-09-05)
Fix README code exemples
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.1.tar.gz
(12.8 kB
view hashes)
Built Distribution
Close
Hashes for timeoutcontext-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcbb47d6c333caccc2257a260c77f8269047a3b6c124feebfe1f02f42c6dbe7e |
|
MD5 | 7037cb232804e0405b8f1afdc500e2bd |
|
BLAKE2b-256 | 3aeb4aba1380fa57740d235af6d007f5dfcd907fbffdc6be8f7d2066e92b40aa |