CMS 3D CMS Logo

Classes | Functions
timeout Namespace Reference

Classes

class  TimedOutExc
 

Functions

def timed_out (timeout)
 
def TimedOutFn (f, timeout, *args, **kwargs)
 

Function Documentation

◆ timed_out()

def timeout.timed_out (   timeout)

Definition at line 23 of file timeout.py.

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

References FastObjects.decorate(), and f.

Referenced by edmIntegrityCheck.IntegrityCheck.testFileTimeOut().

◆ TimedOutFn()

def timeout.TimedOutFn (   f,
  timeout,
args,
**  kwargs 
)

Definition at line 9 of file timeout.py.

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

References f.

f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FastObjects.decorate
def decorate(orig, deco)
Definition: FastObjects.py:11
timeout.TimedOutFn
def TimedOutFn(f, timeout, *args, **kwargs)
Definition: timeout.py:9
timeout.timed_out
def timed_out(timeout)
Definition: timeout.py:23