summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcron/mailpasswds32
1 files changed, 27 insertions, 5 deletions
diff --git a/cron/mailpasswds b/cron/mailpasswds
index 9a0b133e1..6d3b41bfe 100755
--- a/cron/mailpasswds
+++ b/cron/mailpasswds
@@ -24,14 +24,16 @@ rather than sending a single message for each password."""
# This puppy should probably do lots of logging.
-import sys, os, string
+import sys, os, string, time, errno
import paths
from Mailman import MailList
from Mailman import mm_cfg
from Mailman import Utils
-
-users = {} # user: (listname, password, url)
+# Give time for the delivery process-forks to clear every so often, to
+# avoid saturation of the process table. Set zero or negative for no
+# pauses.
+PAUSE_FREQUENCY = 10
def MailAllPasswords(list, users):
"""Send each user their complete list of passwords.
@@ -39,6 +41,7 @@ def MailAllPasswords(list, users):
The list can be any random one - it is only used for the message
delivery mechanism."""
subj = '%s maillist memberships reminder\n' % list.host_name
+ count = PAUSE_FREQUENCY
for user, data in users.items():
table = []
for l, p, u in data:
@@ -60,13 +63,20 @@ def MailAllPasswords(list, users):
recipient = user,
text = text,
sender = mm_cfg.MAILMAN_OWNER,
- add_headers = ["X-No-Archive: yes"])
+ add_headers = ["X-No-Archive: yes"],
+ raw=1)
+ count = count - 1
+ if count == 0:
+ # The pause that refreshes.
+ waitall()
+ count = PAUSE_FREQUENCY
def main():
"""Consolidate all the list/url/password info for each user, so we send
the user a single message with the info for all their lists on this
site."""
list = None
+ users = {} # user: (listname, password, url)
for name in Utils.list_names():
list = MailList.MailList(name, lock = 0)
list_name = list.real_name
@@ -74,7 +84,7 @@ def main():
if not list.send_reminders:
continue
for user, password in list.passwords.items():
- url = list.GetOptionsURL(user)
+ url = list.GetAbsoluteOptionsURL(user)
if reminders_to_admins:
recipient = "%s-admin@%s" % tuple(string.split(user, '@'))
else:
@@ -86,5 +96,17 @@ def main():
if list:
MailAllPasswords(list, users)
+def waitall():
+ """Return only when there are no forked subprocesses running."""
+ try:
+ while 1:
+ os.wait()
+ except os.error, val:
+ if val[0] == errno.ECHILD:
+ # errno.ECHILD: "No child processes"
+ return
+ else:
+ raise val, None, sys.exc_info()[2]
+
if __name__ == "__main__":
main()