CMS 3D CMS Logo

Functions | Variables

cmsPerfSuiteKill Namespace Reference

Functions

def main

Variables

list user = os.environ['USER']

Function Documentation

def cmsPerfSuiteKill::main ( )

Definition at line 10 of file cmsPerfSuiteKill.py.

00011           :
00012     exitcode=0
00013     #First invoke cmsScimarkStop.py to stop eventual cmsScimarks running...
00014     cmsScimarkStop.main()
00015     
00016     #List of executables to spot in ps -ef and kill:
00017     scripts=['cmsPerfSuite.py',
00018              'cmsRelvalreportInput.py',
00019              'cmsRelvalreport.py',
00020              'cmsDriver.py',
00021              'cmsRun',
00022              'cmsScimark2',
00023              'cmsIgProf_Analysis.py',
00024              'igprof-analyse',
00025              'perfreport'
00026              ]
00027          
00028     
00029     print "Looking for processes by user %s"%user
00030     checkProcesses=subprocess.Popen("ps -efww|grep %s"%user,bufsize=4096,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
00031     for line in checkProcesses.stdout:
00032         for executable in scripts:
00033             #print "Looking for %s script"%executable
00034             if executable in line:
00035                 print "Found process %s"%line
00036                 print "Killing it!"
00037                 PID=line.split()[1]
00038                 kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
00039                 print kill_stdouterr
00040                 
00041     #There could be a few more processes spawned after some of the killings... give it a couple of iterations:
00042     i=0
00043     while i<100:
00044         exitcode=0
00045         checkProcesses=subprocess.Popen("ps -efww|grep %s"%user,bufsize=4096,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
00046         for line in checkProcesses.stdout:
00047             for executable in scripts:
00048                 if executable in line:
00049                     print "Something funny going on! It seems I could not kill process:\n%s"%line
00050                     print "SORRY!"
00051                     exitcode=-1
00052         if exitcode>=0:
00053             print "Finally killed all jobs!"
00054             break
00055         i+=1
00056         time.sleep(2)
00057     #Return 0 if all killed, could use the -1 exit code if we decide to put a limit to the number of cycles...
00058     return exitcode


Variable Documentation

list cmsPerfSuiteKill::user = os.environ['USER']

Definition at line 8 of file cmsPerfSuiteKill.py.