From d95db9c7a7e6369546dd00e74feeaf02603333d4 Mon Sep 17 00:00:00 2001
From: Mark Sapiro <msapiro@value.net>
Date: Thu, 29 Sep 2011 17:40:26 -0700
Subject: Eliminated the list cache from the qrunners.  Indirect
 self-references caused lists to never be dropped from the cache which in turn
 caused the qrunners to grow very large in installations with many lists or
 multiple large lists.  Bug #862683.

---
 Mailman/Queue/Runner.py | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

(limited to 'Mailman/Queue')

diff --git a/Mailman/Queue/Runner.py b/Mailman/Queue/Runner.py
index 3ab1bcf0..26bd0c29 100644
--- a/Mailman/Queue/Runner.py
+++ b/Mailman/Queue/Runner.py
@@ -1,4 +1,4 @@
-# Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
+# Copyright (C) 1998-2011 by the Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -20,7 +20,6 @@
 
 import time
 import traceback
-import weakref
 from cStringIO import StringIO
 
 from Mailman import mm_cfg
@@ -198,22 +197,18 @@ class Runner:
         if keepqueued:
             self._switchboard.enqueue(msg, msgdata)
 
-    # Mapping of listnames to MailList instances as a weak value dictionary.
-    _listcache = weakref.WeakValueDictionary()
-
     def _open_list(self, listname):
-        # Cache the open list so that any use of the list within this process
-        # uses the same object.  We use a WeakValueDictionary so that when the
-        # list is no longer necessary, its memory is freed.
-        mlist = self._listcache.get(listname)
-        if not mlist:
-            try:
-                mlist = MailList.MailList(listname, lock=False)
-            except Errors.MMListError, e:
-                syslog('error', 'error opening list: %s\n%s', listname, e)
-                return None
-            else:
-                self._listcache[listname] = mlist
+        # We no longer cache the list instances.  Because of changes to
+        # MailList.py needed to avoid not reloading an updated list, caching
+        # is not as effective as it once was.  Also, with OldStyleMemberships
+        # as the MemberAdaptor, there was a self-reference to the list which
+        # kept all lists in the cache.  Changing this reference to a
+        # weakref.proxy created other issues.
+        try:
+            mlist = MailList.MailList(listname, lock=False)
+        except Errors.MMListError, e:
+            syslog('error', 'error opening list: %s\n%s', listname, e)
+            return None
         return mlist
 
     def _log(self, exc):
-- 
cgit v1.2.3