~andreserl/maas/python3_qa_lab_tests

« back to all changes in this revision

Viewing changes to timeout.py

  • Committer: jtv at canonical
  • Date: 2014-09-25 06:10:31 UTC
  • mto: This revision was merged to the branch mainline in revision 263.
  • Revision ID: jtv@canonical.com-20140925061031-i32kry20r536qnaz
Add lint test, and fix lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# From
2
 
# http://stackoverflow.com/questions/2281850/timeout-function-if-it-takes-too-long-to-finish
 
1
# From StackOverflow question: "timeout function if it itakes too long to
 
2
# finish": http://bit.ly/1g1wHpm
3
3
from functools import wraps
4
4
import errno
5
5
import os
6
6
import signal
7
7
 
 
8
 
8
9
class TimeoutError(Exception):
9
10
    pass
10
11
 
 
12
 
11
13
def timeout(seconds=10, error_message=os.strerror(errno.ETIME)):
12
14
    def decorator(func):
13
15
        def _handle_timeout(signum, frame):