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 check.py conf.py
Date Mon, 06 Oct 2003 14:04:16 GMT
ajack       2003/10/06 07:04:15

  Modified:    python/gump launcher.py check.py conf.py
  Log:
  Add timeout on launched commands (UNIX only)
  Defaults to 30 minutes, will allow override some time.
  
  Revision  Changes    Path
  1.10      +21 -2     jakarta-gump/python/gump/launcher.py
  
  Index: launcher.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/launcher.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- launcher.py	30 Sep 2003 03:52:24 -0000	1.9
  +++ launcher.py	6 Oct 2003 14:04:15 -0000	1.10
  @@ -65,7 +65,8 @@
   import os
   import sys
   import logging
  -
  +import signal
  +    
   from string import split
   
   from gump import log, gumpSafeName
  @@ -255,6 +256,16 @@
       result.exit_code=0
       result.status=CMD_STATUS_SUCCESS  
       return result
  +
  +def killChildren():
  +    pid=os.getpid()
  +    log.info('Kill all children for ' + str(pid))    
  +    os.system('pkill -P ' + str(pid))
  +    
  +def timeoutHandler(signum, frame):
  +    log.info('Signal handler called with signal: ' + str(signum))
  +    killChildren()
  +    raise Error, "Timeout"
       
   def execute(cmd,tmp=dir.tmp):
       res=CmdResult(cmd)
  @@ -323,9 +334,17 @@
           #############################################################                
           log.info('Executing: ' + execString + ' (Output to ' + str(outputFile) + ')')
       
  +        # Set the signal handler and an N-second alarm
  +        if not os.name == 'dos' and not os.name == 'nt':
  +            signal.signal(signal.SIGALRM, timeoutHandler)
  +            signal.alarm(setting.timeout)
  +
           # Execute Command & Wait
           result.exit_code=os.system(execString + ' >>' + str(outputFile) + ' 2>&1')
       
  +        if not os.name == 'dos' and not os.name == 'nt':
  +            signal.alarm(0)          # Disable the alarm
  +
           # Process Outputs (exit_code and stderr/stdout)
           if result.exit_code < 0:
             result.status=CMD_STATUS_TIMED_OUT
  @@ -344,7 +363,7 @@
                   result.output=outputFile
               else:
                   os.remove(outputFile)
  -    
  +                
         except Exception, details :
           log.error('Failed to launch command. Details: ' + str(details))
           
  
  
  
  1.24      +7 -3      jakarta-gump/python/gump/check.py
  
  Index: check.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/check.py,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- check.py	29 Sep 2003 22:50:07 -0000	1.23
  +++ check.py	6 Oct 2003 14:04:15 -0000	1.24
  @@ -152,6 +152,9 @@
           context.noRSync=1
           context.addWarning('"rsync" command not found, so attempting recursive copy "cp
-R"')
           
  +    if not checkExecutable(workspace, context, 'pkill','-help',0): 
  +        context.noPKill=1
  +        context.addWarning('"pkill" command not found, no process clean-ups can occur')
       
       
       # :TODO:
       # Need to check javac classes are on CLASSPATH
  @@ -169,6 +172,7 @@
       except Exception, details:
           ok=0
           log.error('Failed to detect [' + command + '] : ' + str(details))
  +        result=None
          
       # Update Context
       context.performedWork(CommandWorkItem(WORK_TYPE_CHECK,cmd,result))
  
  
  
  1.17      +5 -3      jakarta-gump/python/gump/conf.py
  
  Index: conf.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/conf.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- conf.py	28 Sep 2003 15:05:43 -0000	1.16
  +++ conf.py	6 Oct 2003 14:04:15 -0000	1.17
  @@ -113,6 +113,8 @@
       
       datetimeformat="%a, %d %b %Y %H:%M:%S (%Z)"
       
  +    timeout=60*30 # 30 minutes (in seconds)
  +    
   class switch:
       """Configuration of switches """   
       optimize=0 # Optimize (at risk to exact correctness) anywhere one can
  
  
  

Mime
View raw message