Changeset 3040 for pykota/trunk/bin/cupspykota
- Timestamp:
- 10/16/06 13:30:17 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r3036 r3040 140 140 0600) 141 141 except OSError, error : 142 # IMPORTANT : we don't check anymore if the other process 143 # is still alive, otherwise we could inadvertantly delete 144 # a lock file created by a different print server in the 145 # same directory (load balancing). 146 # I think the lock is removed in all cases anyway, excepted 147 # when the admin kills -9 cupspykota. 142 148 if error.errno == errno.EEXIST : 143 self.logdebug("Lock not available. ")149 self.logdebug("Lock not available. Waiting a bit...") 144 150 else : 145 self.logdebug("Lock not available : %s" % error) 146 try : 147 try : 148 lockfobj = open(self.lockfilename, "r") 149 oldpid = int(lockfobj.readline().strip()) 150 except IOError : 151 self.logdebug("Lock file has probably been deleted in the meantime.") 152 except ValueError : 153 self.logdebug("Invalid content in existing lock file.") 154 else : 155 try : 156 # Is the old process still alive ? 157 os.kill(oldpid, 0) 158 except OSError : 159 # old process is dead, we delete the lock file 160 self.logdebug("Old process (PID %i) is dead." % oldpid) 161 os.unlink(self.lockfilename) 162 self.logdebug("Lock file %s removed." % self.lockfilename) 163 else : 164 self.logdebug("Old process (PID %i) still alive, waiting a bit..." % oldpid) 165 time.sleep(0.25) # No hurry :) 166 finally : 167 try : 168 lockfobj.close() 169 except NameError : 170 pass 151 self.logdebug("Lock not available : %s. Waiting a bit..." % error) 152 time.sleep(0.25) # No hurry :) 171 153 else : 172 154 os.write(self.lockfile, str(self.pid)) … … 558 540 os.unlink(self.lockfilename) 559 541 except : 560 self. logdebug("Problem while removing lock file %s" % self.lockfilename)542 self.printInfo("Problem while removing lock file %s" % self.lockfilename, "error") 561 543 else : 562 544 self.logdebug("Lock file %s removed." % self.lockfilename)