CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
timeout Namespace Reference

Classes

class  TimedOutExc
 

Functions

def timed_out
 
def TimedOutFn
 

Function Documentation

def timeout.timed_out (   timeout)

Definition at line 23 of file timeout.py.

References FastObjects.decorate(), and f.

Referenced by edmIntegrityCheck.IntegrityCheck.testFileTimeOut().

23 
24 def timed_out(timeout):
25  def decorate(f):
26  def handler(signum, frame):
27  raise TimedOutExc()
28 
29  def new_f(*args, **kwargs):
30  old = signal.signal(signal.SIGALRM, handler)
31  signal.alarm(timeout)
32 
33  time_up = True
34  try:
35  result = f(*args, **kwargs)
36  time_up = False
37  finally:
38  signal.signal(signal.SIGALRM, old)
39  signal.alarm(0)
40  if time_up:
41  raise TimedOutExc()
42  return result
43 
44  new_f.func_name = f.func_name
45  return new_f
46 
47  return decorate
def timed_out
Definition: timeout.py:23
double f[11][100]
def timeout.TimedOutFn (   f,
  timeout,
  args,
  kwargs 
)

Definition at line 9 of file timeout.py.

References f.

9 
10 def TimedOutFn(f, timeout, *args, **kwargs):
11  def handler(signum, frame):
12  raise TimedOutExc()
13 
14  old = signal.signal(signal.SIGALRM, handler)
15  signal.alarm(timeout)
16  try:
17  result = f(*args, **kwargs)
18  finally:
19  signal.signal(signal.SIGALRM, old)
20  signal.alarm(0)
21  return result
22 
double f[11][100]
def TimedOutFn
Definition: timeout.py:9