Update of /cvsroot/mailman/mailman/Mailman
In directory usw-pr-cvs1:/tmp/cvs-serv30394/Mailman

Modified Files:
        MailList.py 
Log Message:
Make it much cheaper to call Load(), especially when the state hasn't
changed since the last Load().  This means it will be cost effective
to reload the state when necessary in qrunners which don't lock the
list (e.g. OutgoingRunner).  Specifically,

InitTempVars(): Set a temporary timestamp attribute, which gets the
mtime of the config.pck file upon successful load.

__save(): When we save the file, set the timestamp to the file's mtime
(we just saved it so it must be up-to-date -- since this is done with
the list lock acquired, there shouldn't be a race).

__load(): If the file's mtime is <= the current timestamp, then we've
got the most current state.  This method can now return (None, None)
meaning we didn't need to load anything.

Load(): Watch for dict is None and e is None, meaning we didn't need
to load anything.


Index: MailList.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/MailList.py,v
retrieving revision 2.66
retrieving revision 2.67
diff -C2 -d -r2.66 -r2.67
*** MailList.py 26 Mar 2002 21:10:02 -0000      2.66
--- MailList.py 1 Apr 2002 16:31:25 -0000       2.67
***************
*** 224,227 ****
--- 224,231 ----
      def InitTempVars(self, name):
          """Set transient variables of this and inherited classes."""
+         # The timestamp is set whenever we load the state from disk.  If our
+         # timestamp is newer than the modtime of the config.pck file, we don't
+         # need to reload, otherwise... we do.
+         self.__timestamp = 0
          self.__lock = LockFile.LockFile(
              os.path.join(mm_cfg.LOCK_DIR, name or '<site>') + '.lock',
***************
*** 448,451 ****
--- 452,457 ----
              if e.errno <> errno.ENOENT: raise
          os.rename(fname_tmp, fname)
+         # Reset the timestamp
+         self.__timestamp = os.path.getmtime(fname)
  
      def Save(self):
***************
*** 487,491 ****
              loadfunc = cPickle.load
          else:
!             assert 0
          try:
              fp = open(dbfile)
--- 493,501 ----
              loadfunc = cPickle.load
          else:
!             assert 0, 'Bad database file name'
!         mtime = os.path.getmtime(dbfile)
!         if mtime <= self.__timestamp:
!             # File is not newer
!             return None, None
          try:
              fp = open(dbfile)
***************
*** 503,506 ****
--- 513,518 ----
          finally:
              fp.close()
+         # Update timestamp
+         self.__timestamp = mtime
          return dict, None
  
***************
*** 522,529 ****
              dict, e = self.__load(file)
              if dict is None:
!                 # Had problems with this file; log it and try the next one.
!                 syslog('error',
!                        '%s config file was corrupt, trying fallback: %s',
!                        self.internal_name(), file)
              else:
                  break
--- 534,544 ----
              dict, e = self.__load(file)
              if dict is None:
!                 if e is not None:
!                     # Had problems with this file; log it and try the next one.
!                     syslog('error', "couldn't load config file %s\n%s",
!                            file, e)
!                 else:
!                     # We already have the most up-to-date state
!                     return
              else:
                  break


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/mailman-checkins

Reply via email to