Logo Search packages:      
Sourcecode: nagios-plugins version File versions

def utils::Task::Wait (   self,
  idlefunc = None,
  interval = 0.1 
)

Wait for the subprocess to terminate.
   If the process has already terminated, this function will return
   immediately without raising an error.
   optional arguments:
       idlefunc=None: a callable object (function, class, bound method)
              that will be called every 0.1 second (or see
              the 'interval' variable) while waiting for
              the subprocess to terminate. This can be the
              Tkinter 'update' procedure, such that the GUI
              doesn't die during the run. If this is set to
              'None', the process will really wait. idlefunc
              should ideally not take a very long time to
              complete...
       interval=0.1: The interval (in seconds) with which the 'idlefunc'
             (if any) will be called.
   return value:
       the exit status of the subprocess (0 if successful).

Definition at line 165 of file utils.py.

00165                                              :
        """Wait for the subprocess to terminate.
           If the process has already terminated, this function will return
           immediately without raising an error.
           optional arguments:
               idlefunc=None: a callable object (function, class, bound method)
                              that will be called every 0.1 second (or see
                              the 'interval' variable) while waiting for
                              the subprocess to terminate. This can be the
                              Tkinter 'update' procedure, such that the GUI
                              doesn't die during the run. If this is set to
                              'None', the process will really wait. idlefunc
                              should ideally not take a very long time to
                              complete...
               interval=0.1: The interval (in seconds) with which the 'idlefunc'
                             (if any) will be called.
           return value:
               the exit status of the subprocess (0 if successful).
        """
        if self.status!=None:
            # Already finished
            return self.status
        if callable(idlefunc):
            while 1:
                try:
                    pid,status=os.waitpid(self.pid,os.WNOHANG)
                    if pid==self.pid:
                        self.status=status
                        return status
                    else:
                        idlefunc()
                        time.sleep(interval)
                except KeyboardInterrupt:
                    # Send the interrupt to the inferior process.
                    self.Kill(signal=signal.SIGINT)
        elif idlefunc:
            raise error("Non-callable idle function")
        else:
            while 1:
                try:
                    pid,status=os.waitpid(self.pid,0)
                    self.status=status
                    return status
                except KeyboardInterrupt:
                    # Send the interrupt to the inferior process.
                    self.Kill(signal=signal.SIGINT)

    def Kill(self,signal=signal.SIGTERM):


Generated by  Doxygen 1.6.0   Back to index