Changeset 3823:697e888115bc in livinglogic.python.xist

Show
Ignore:
Timestamp:
07/09/09 12:04:11 (10 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Tags:
rel-3-6-6
Message:

Fixed handling of empty pid files in ll.sisyphus.

This fixes issue #11 reported by Jarek Zgoda.

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • NEWS.rst

    r3785 r3823  
     1Changes in 3.6.6 (released 07/09/2009) 
     2-------------------------------------- 
     3 
     4*   Fixed handling of empty pid files in :mod:`ll.sisyphus` (Fixes issue #11 
     5    reported by Jarek Zgoda). 
     6 
     7 
    18Changes in 3.6.5 (released 06/02/2009) 
    29-------------------------------------- 
  • setup.py

    r3785 r3823  
    201201args = dict( 
    202202    name="ll-xist", 
    203     version="3.6.5", 
     203    version="3.6.6", 
    204204    description="Extensible HTML/XML generator, cross-platform templating language and various other tools", 
    205205    long_description=descr, 
  • src/ll/sisyphus.py

    r3691 r3823  
    296296        else: 
    297297            lastmodified = datetime.datetime.fromtimestamp(os.fstat(file.fileno()).st_mtime) 
    298             pid = int(file.read()) 
    299             file.close() 
    300  
    301             # Check if this process really exists, if not continue as if the pid file wasn't there 
    302298            try: 
    303                 os.kill(pid, 0) 
    304             except OSError, exc: 
    305                 if exc[0] != errno.ESRCH: 
    306                     raise 
     299                pid = int(file.read()) 
     300            except ValueError: 
     301                # disk may have been full 
     302                file.close() 
    307303                self.__writepid() 
    308                 msg = "ignoring bogus pid file %s (process with pid %d doesn't exist)" % (self.pidfilename, pid) 
    309                 self.logError(msg) 
     304                self.logProgress("ignoring bogus pid file %s (invalid content)" % self.pidfilename) 
    310305            else: 
    311                 if self.maxruntime and self.starttime-lastmodified > self.maxruntime: # the job is to old, so it probably hangs => kill it 
    312                     try: 
    313                         os.kill(pid, 9) 
    314                     except OSError, exc: 
    315                         if exc[0] != errno.ESRCH: # there was no process 
    316                             raise 
     306                file.close() 
     307                # Check if this process really exists, if not continue as if the pid file wasn't there 
     308                try: 
     309                    os.kill(pid, 0) 
     310                except OSError, exc: 
     311                    if exc[0] != errno.ESRCH: 
     312                        raise 
    317313                    self.__writepid() 
    318                     msg = "killed previous job running with pid %d (ran %s seconds; %s allowed); here we go" % (pid, _formattimedelta(self.starttime-lastmodified), _formattimedelta(self.maxruntime)) 
     314                    msg = "ignoring bogus pid file %s (process with pid %d doesn't exist)" % (self.pidfilename, pid) 
    319315                    self.logError(msg) 
    320                     if self.printkills: 
    321                         print msg 
    322316                else: 
    323                     msg = "Job still running (for %s; %s allowed; started on %s) with pid %d (according to %s)" % (_formattimedelta(self.starttime-lastmodified), _formattimedelta(self.maxruntime), _formattime(lastmodified), pid, self.pidfilename) 
    324                     self.logErrorOnly(msg) 
    325                     return # Return without calling :meth:`execute` 
     317                    if self.maxruntime and self.starttime-lastmodified > self.maxruntime: # the job is to old, so it probably hangs => kill it 
     318                        try: 
     319                            os.kill(pid, 9) 
     320                        except OSError, exc: 
     321                            if exc[0] != errno.ESRCH: # there was no process 
     322                                raise 
     323                        self.__writepid() 
     324                        msg = "killed previous job running with pid %d (ran %s seconds; %s allowed); here we go" % (pid, _formattimedelta(self.starttime-lastmodified), _formattimedelta(self.maxruntime)) 
     325                        self.logError(msg) 
     326                        if self.printkills: 
     327                            print msg 
     328                    else: 
     329                        msg = "Job still running (for %s; %s allowed; started on %s) with pid %d (according to %s)" % (_formattimedelta(self.starttime-lastmodified), _formattimedelta(self.maxruntime), _formattime(lastmodified), pid, self.pidfilename) 
     330                        self.logErrorOnly(msg) 
     331                        return # Return without calling :meth:`execute` 
    326332 
    327333        try: