diff options
| author | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2014-12-07 12:08:31 -0500 |
|---|---|---|
| committer | jeanpouget-abadie <jean.pougetabadie@gmail.com> | 2014-12-07 12:08:31 -0500 |
| commit | 9de35421f25bf45158187daea4ddfedd1c93f3d8 (patch) | |
| tree | f917008b6363a2b9dbff7855781f4fd5a10a6e94 /jpa_test/timeout.py | |
| parent | 6c874852773329f6fecbbc54476b30a37aa85b79 (diff) | |
| download | cascades-9de35421f25bf45158187daea4ddfedd1c93f3d8.tar.gz | |
renaming directory + creating dataset directory
Diffstat (limited to 'jpa_test/timeout.py')
| -rw-r--r-- | jpa_test/timeout.py | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/jpa_test/timeout.py b/jpa_test/timeout.py deleted file mode 100644 index d7381c3..0000000 --- a/jpa_test/timeout.py +++ /dev/null @@ -1,25 +0,0 @@ -from functools import wraps -import errno -import os -import signal - -class TimeoutError(Exception): - pass - -def timeout(seconds=10, error_message=os.strerror(errno.ETIME)): - def decorator(func): - def _handle_timeout(signum, frame): - raise TimeoutError(error_message) - - def wrapper(*args, **kwargs): - signal.signal(signal.SIGALRM, _handle_timeout) - signal.alarm(seconds) - try: - result = func(*args, **kwargs) - finally: - signal.alarm(0) - return result - - return wraps(func)(wrapper) - - return decorator |
