diff options
| author | viega | 1998-06-24 08:37:32 +0000 |
|---|---|---|
| committer | viega | 1998-06-24 08:37:32 +0000 |
| commit | dac08e873ddddcffa24bfebc1b21a6334de177f9 (patch) | |
| tree | f7e8e43813d68f5efc612070febde4fc05126424 /Mailman/LockFile.py | |
| parent | 4ed248c05f03abdb216d2273c79704f104d9114d (diff) | |
| download | mailman-dac08e873ddddcffa24bfebc1b21a6334de177f9.tar.gz mailman-dac08e873ddddcffa24bfebc1b21a6334de177f9.tar.zst mailman-dac08e873ddddcffa24bfebc1b21a6334de177f9.zip | |
Diffstat (limited to 'Mailman/LockFile.py')
| -rw-r--r-- | Mailman/LockFile.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Mailman/LockFile.py b/Mailman/LockFile.py index b77bb44d7..53715ad34 100644 --- a/Mailman/LockFile.py +++ b/Mailman/LockFile.py @@ -66,29 +66,33 @@ class FileLock: while 1: os.link(self.lockfile, self.tmpfname) if os.stat(self.tmpfname)[3] == 2: - file = open(self.tmpfname, 'w+') - file.write(`os.getpid(),self.tmpfname`) - file.close() - self.is_locked = 1 - break + file = open(self.tmpfname, 'w+') + file.write(`os.getpid(),self.tmpfname`) + file.close() + self.is_locked = 1 + break if timeout and timeout_time < time.time(): - raise TimeOutError + raise TimeOutError file = open(self.tmpfname, 'r') try: pid,winner = eval(file.read()) except SyntaxError: # no info in file... *can* happen file.close() + os.unlink(self.tmpfname) continue file.close() if pid <> last_pid: - last_pid = pid - stime = time.time() + last_pid = pid + stime = time.time() if (stime + self.hung_timeout < time.time()) and self.hung_timeout > 0: - file = open(self.tmpfname, 'w+') - file.write(`os.getpid(),self.tmpfname`) - os.unlink(winner) - self.is_locked = 1 - break + file = open(self.tmpfname, 'w+') + file.write(`os.getpid(),self.tmpfname`) + try: + os.unlink(winner) + except os.error: + pass + os.unlink(self.tmpfname) + continue os.unlink(self.tmpfname) time.sleep(self.sleep_interval) # This could error if the lock is stolen. You must catch it. |
