A signal based timeout context manager
Project description
A signal based timeout context manager and decorator.
Usage
As a context manager:
from timeoutcontext import timeout, TimeoutException
from time import sleep
try:
with timeout(1):
sleep(2)
except TimeoutException:
print('timeout')
As a decorator:
from timeoutcontext import timeout, TimeoutException
from time import sleep
@timeout(1)
def wait():
sleep(2)
try:
wait()
except TimeoutException:
print('timeout')
License
Free software: BSD license
History
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.0.0.tar.gz
(12.4 kB
view hashes)
Built Distribution
Close
Hashes for timeoutcontext-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e50a7bc6093e2403896160b5e9e655d0018394bed1864fa020d9fd6ac731994 |
|
MD5 | e1bf54e87b00e4902dd9a477115fc4c4 |
|
BLAKE2b-256 | 36625de7d9cb32361fb4a014e95f7ab608e3c6d98b41d9d508fa8dc193c46589 |