CMS 3D CMS Logo

Functions | Variables
cmsPerfSuiteKill Namespace Reference

Functions

def main ()
 

Variables

 user
 

Function Documentation

def cmsPerfSuiteKill.main ( )

Definition at line 11 of file cmsPerfSuiteKill.py.

References cmsScimarkStop.main(), and edm.print().

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

Variable Documentation

cmsPerfSuiteKill.user

Definition at line 9 of file cmsPerfSuiteKill.py.