gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: jakarta-gump/python/gump launcher.py
Date Mon, 20 Oct 2003 18:55:10 GMT
ajack       2003/10/20 11:55:10

  Modified:    python/gump launcher.py
  Log:
  I think I finally have it (at least for *nix) ... launched processes will be
  killed if the overrun...
  
  Revision  Changes    Path
  1.27      +27 -23    jakarta-gump/python/gump/launcher.py
  
  Index: launcher.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/launcher.py,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- launcher.py	20 Oct 2003 18:44:52 -0000	1.26
  +++ launcher.py	20 Oct 2003 18:55:10 -0000	1.27
  @@ -286,27 +286,33 @@
   def killChildProcesses():
       gumpid=default.gumpid
       log.warn('Kill all child processed (anything launched by Gumpy) [PID' + str(gumpid)
+ ']')    
  -    output = dir.tmp + '/childPIDs.txt'
  -    command='pgrep -P ' + str(gumpid) + ' -l > ' + output
  -    if os.system(command):
  -        ids=None
  -        try:     
  -            ids=open(output,'r')
  -    
  -            line=ids.readline()
  -            while line:            
  -                parts=line.split(' ')
  -                childPID=int(parts[0])
  -                process=parts[1]
  -                if not process=='python':
  -                    log.warn('Terminate PID' + str(childPID) + '] Process: [' + process
+ ']')            
  -                    os.kill(childPID,signal.SIGKILL)
  +    pidsFile = dir.tmp + '/childPIDs.txt'
  +    command='pgrep -P ' + str(gumpid) + ' -l > ' + pidsFile
  +    os.system(command):
  +    
  +    ids=None
  +    try:     
  +        ids=open(pidsFile,'r')
  +    
  +        line=ids.readline()
  +        while line:            
  +            parts=line.split()
  +            childPID=int(parts[0])
  +            process=parts[1]
  +            if not process=='python':
  +                log.warn('Terminate PID [' + str(childPID) + '] Process: [' + process +
']')            
  +                os.kill(childPID,signal.SIGKILL)
               
  -                # Get next PID/process combination
  -                line=ids.readline()
  -        finally:
  -            if ids: ids.close()
  -    log.warn('Terminated All.')                            
  +            # Get next PID/process combination
  +            line=ids.readline()
  +    finally:
  +        if ids: ids.close()
  +    
  +    if os.path.exists(pidsFile):
  +        os.remove(pidsFile)    
  +    
  +    log.warn('Terminated All.')   
  +    sys.exit(0)                         
       
   def execute(cmd,tmp=dir.tmp):
       res=CmdResult(cmd)
  @@ -384,8 +390,6 @@
           # Execute Command & Wait
           result.exit_code=os.system(execString + ' >>' + str(outputFile) + ' 2>&1')
           
  -        log.info('Executed. ExitCode: ' + str(result.exit_code))
  -    
           # Stop it (if still running)
           timer.cancel()              
   
  @@ -464,6 +468,6 @@
     result = execute(cmd)  
   #  dump(result);
     
  -  exit(0)
  +  sys.exit(0)
     
     
  
  
  

Mime
View raw message