CMS 3D CMS Logo

Functions | Variables
cmsPerfSuiteKill Namespace Reference

Functions

def main ()
 

Variables

 user
 

Function Documentation

def cmsPerfSuiteKill.main ( )

Definition at line 10 of file cmsPerfSuiteKill.py.

References cmsScimarkStop.main().

10 def main():
11  exitcode=0
12  #First invoke cmsScimarkStop.py to stop eventual cmsScimarks running...
14 
15  #List of executables to spot in ps -ef and kill:
16  scripts=['cmsPerfSuite.py',
17  'cmsRelvalreportInput.py',
18  'cmsRelvalreport.py',
19  'cmsDriver.py',
20  'cmsRun',
21  'cmsScimark2',
22  'cmsIgProf_Analysis.py',
23  'igprof-analyse',
24  'perfreport'
25  ]
26 
27 
28  print "Looking for processes by user %s"%user
29  checkProcesses=subprocess.Popen("ps -efww|grep %s"%user,bufsize=4096,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
30  for line in checkProcesses.stdout:
31  for executable in scripts:
32  #print "Looking for %s script"%executable
33  if executable in line:
34  print "Found process %s"%line
35  print "Killing it!"
36  PID=line.split()[1]
37  kill_stdouterr=subprocess.Popen("kill %s"%PID,shell=True,stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout.read()
38  print kill_stdouterr
39 
40  #There could be a few more processes spawned after some of the killings... give it a couple of iterations:
41  i=0
42  while i<100:
43  exitcode=0
44  checkProcesses=subprocess.Popen("ps -efww|grep %s"%user,bufsize=4096,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
45  for line in checkProcesses.stdout:
46  for executable in scripts:
47  if executable in line:
48  print "Something funny going on! It seems I could not kill process:\n%s"%line
49  print "SORRY!"
50  exitcode=-1
51  if exitcode>=0:
52  print "Finally killed all jobs!"
53  break
54  i+=1
55  time.sleep(2)
56  #Return 0 if all killed, could use the -1 exit code if we decide to put a limit to the number of cycles...
57  return exitcode
58 

Variable Documentation

cmsPerfSuiteKill.user

Definition at line 8 of file cmsPerfSuiteKill.py.