diff options
| author | bwarsaw | 1999-12-14 04:22:05 +0000 |
|---|---|---|
| committer | bwarsaw | 1999-12-14 04:22:05 +0000 |
| commit | ad8f47e4534485cf31a2f0ade2d45e668bb161fc (patch) | |
| tree | 4fa3ab2f8fcdb85015296b0882c6891b2ed1ccba /Mailman/LockFile.py | |
| parent | 231bd5d5ab1ae8fbbfce208d5828be8f9fbc54ed (diff) | |
| download | mailman-ad8f47e4534485cf31a2f0ade2d45e668bb161fc.tar.gz mailman-ad8f47e4534485cf31a2f0ade2d45e668bb161fc.tar.zst mailman-ad8f47e4534485cf31a2f0ade2d45e668bb161fc.zip | |
Diffstat (limited to 'Mailman/LockFile.py')
| -rw-r--r-- | Mailman/LockFile.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Mailman/LockFile.py b/Mailman/LockFile.py index 362a32cd3..0cff28228 100644 --- a/Mailman/LockFile.py +++ b/Mailman/LockFile.py @@ -40,6 +40,7 @@ DEFAULT_SLEEP_INTERVAL = .25 from Mailman.Logging.StampedLogger import StampedLogger +_logfile = None @@ -90,10 +91,7 @@ class LockFile: self.__tmpfname = "%s.%s.%d" % (lockfile, socket.gethostname(), os.getpid()) - if withlogging: - self.__log = StampedLogger('locks', self.__tmpfname) - else: - self.__log = None + self.__withlogging = withlogging self.__kickstart() def set_lifetime(self, lifetime): @@ -103,10 +101,12 @@ class LockFile: self.__lifetime = lifetime def __writelog(self, msg): - if self.__log: - self.__log.write(msg) - if msg and msg[-1] <> '\n': - self.__log.write('\n') + global _logfile + if self.__withlogging: + if not _logfile: + _logfile = StampedLogger('locks', manual_reprime=1) + head, tail = os.path.split(self.__lockfile) + _logfile.write('%s %s\n' % (tail, msg)) def refresh(self, newlifetime=None): """Refresh the lock. @@ -128,8 +128,6 @@ class LockFile: def __del__(self): if self.locked(): self.unlock() - if self.__log: - self.__log.close() def __kickstart(self, force=0): # forcing means to remove the original lock file, and create a new |
