CMS 3D CMS Logo

Public Member Functions | Public Attributes

CrabWatch::CrabWatch Class Reference

Inherits threading::Thread.

List of all members.

Public Member Functions

def __init__
def run
def setThreshold

Public Attributes

 action
 finish
 lock
 project
 threshold

Detailed Description

Definition at line 6 of file CrabWatch.py.


Constructor & Destructor Documentation

def CrabWatch::CrabWatch::__init__ (   self,
  project,
  action = getOutput 
)

Definition at line 10 of file CrabWatch.py.

00011                                                    :
00012         Thread.__init__(self)
00013         self.project = project
00014         self.action = action
00015         self.threshold = 100.0
00016 
00017         self.lock = Lock()
00018         self.finish = Event() 
 

Member Function Documentation

def CrabWatch::CrabWatch::run (   self)

Definition at line 22 of file CrabWatch.py.

00023                  :
00024         exit = False
00025         failed=0
00026         while not exit:
00027             #if checkStatus(self.project,80.0): break
00028             try:
00029                status = crabStatus(self.project)
00030             except CrabException:
00031                failed+=1
00032                print "Crab retrieve status failed (",failed,")"
00033                if failed>10:
00034                   raise 
00035             else:
00036                statusNew = convertStatus(status)
00037                print "Relative percentage finished: %.0f%%" % statusNew['Finished']
00038                print "Relative percentage failed  : %.0f%%" % statusNew['Failed']
00039                print "Relative percentage running : %.0f%%" % statusNew['Running']
00040                if statusNew['Failed'] > 50.0: raise RuntimeError,'Too many jobs have failed (%.0f%%).' % statusNew['Failed']
00041                if statusNew['Finished'] >= self.threshold: break
00042    
00043                self.lock.acquire()
00044                if self.finish.isSet(): exit = True 
00045                self.lock.release()
00046  
00047             if not exit: time.sleep(180)
00048  
00049         print "Finished..."
00050 
00051         if self.action: self.action(self.project)

def CrabWatch::CrabWatch::setThreshold (   self,
  threshold 
)

Definition at line 19 of file CrabWatch.py.

00020                                     :
00021         self.threshold = float(threshold)


Member Data Documentation

Definition at line 10 of file CrabWatch.py.

Definition at line 10 of file CrabWatch.py.

Definition at line 10 of file CrabWatch.py.

Definition at line 10 of file CrabWatch.py.

Definition at line 10 of file CrabWatch.py.