summaryrefslogtreecommitdiff
path: root/Mailman/Queue/OutgoingRunner.py
diff options
context:
space:
mode:
authorbwarsaw2003-05-03 02:17:32 +0000
committerbwarsaw2003-05-03 02:17:32 +0000
commite84aa1bb8ada39468adcbf487aaa10fe41f99ca7 (patch)
treeccee1b04a6a93c0c75cea40db087c8bc8d8d1e8f /Mailman/Queue/OutgoingRunner.py
parent2418bfc4d8310c4f9b105471bd1ffe21308517e1 (diff)
downloadmailman-e84aa1bb8ada39468adcbf487aaa10fe41f99ca7.tar.gz
mailman-e84aa1bb8ada39468adcbf487aaa10fe41f99ca7.tar.zst
mailman-e84aa1bb8ada39468adcbf487aaa10fe41f99ca7.zip
Diffstat (limited to 'Mailman/Queue/OutgoingRunner.py')
-rw-r--r--Mailman/Queue/OutgoingRunner.py66
1 files changed, 34 insertions, 32 deletions
diff --git a/Mailman/Queue/OutgoingRunner.py b/Mailman/Queue/OutgoingRunner.py
index 11c94dfeb..0ff18df62 100644
--- a/Mailman/Queue/OutgoingRunner.py
+++ b/Mailman/Queue/OutgoingRunner.py
@@ -29,11 +29,12 @@ from Mailman import Message
from Mailman import Errors
from Mailman import LockFile
from Mailman.Queue.Runner import Runner
+from Mailman.Queue.Switchboard import Switchboard
from Mailman.Logging.Syslog import syslog
# This controls how often _doperiodic() will try to deal with deferred
# permanent failures. It is a count of calls to _doperiodic()
-DEAL_WITH_PERMFAILURES_EVERY = 1
+DEAL_WITH_PERMFAILURES_EVERY = 10
try:
True, False
@@ -59,12 +60,9 @@ class OutgoingRunner(Runner):
# error log. It gets reset if the message was successfully sent, and
# set if there was a socket.error.
self.__logged = False
+ self.__retryq = Switchboard(mm_cfg.RETRYQUEUE_DIR)
def _dispose(self, mlist, msg, msgdata):
- # See if we should retry delivery of this message again.
- deliver_after = msgdata.get('deliver_after', 0)
- if time.time() < deliver_after:
- return True
# Make sure we have the most up-to-date state
mlist.Load()
try:
@@ -98,33 +96,30 @@ class OutgoingRunner(Runner):
# For permanent failures, make a copy of the message for bounce
# handling. I'm not sure this is necessary, or the right thing to
# do.
- pcnt = len(e.permfailures)
- msgcopy = copy.deepcopy(msg)
- self._permfailures.setdefault(mlist, []).extend(
- zip(e.permfailures, [msgcopy] * pcnt))
- # Temporary failures
- if not e.tempfailures:
- # Don't need to keep the message queued if there were only
- # permanent failures.
- return False
- now = time.time()
- recips = e.tempfailures
- last_recip_count = msgdata.get('last_recip_count', 0)
- deliver_until = msgdata.get('deliver_until', now)
- if len(recips) == last_recip_count:
- # We didn't make any progress, so don't attempt delivery any
- # longer. BAW: is this the best disposition?
- if now > deliver_until:
- return False
- else:
- # Keep trying to delivery this message for a while
- deliver_until = now + mm_cfg.DELIVERY_RETRY_PERIOD
- msgdata['last_recip_count'] = len(recips)
- msgdata['deliver_until'] = deliver_until
- msgdata['deliver_after'] = now + mm_cfg.DELIVERY_RETRY_WAIT
- msgdata['recips'] = recips
- # Requeue
- return True
+ if e.permfailures:
+ pcnt = len(e.permfailures)
+ msgcopy = copy.deepcopy(msg)
+ self._permfailures.setdefault(mlist, []).extend(
+ zip(e.permfailures, [msgcopy] * pcnt))
+ # Move temporary failures to the qfiles/retry queue which will
+ # occasionally move them back here for another shot at delivery.
+ if e.tempfailures:
+ now = time.time()
+ recips = e.tempfailures
+ last_recip_count = msgdata.get('last_recip_count', 0)
+ deliver_until = msgdata.get('deliver_until', now)
+ if len(recips) == last_recip_count:
+ # We didn't make any progress, so don't attempt delivery
+ # any longer. BAW: is this the best disposition?
+ if now > deliver_until:
+ return False
+ else:
+ # Keep trying to delivery this message for a while
+ deliver_until = now + mm_cfg.DELIVERY_RETRY_PERIOD
+ msgdata['last_recip_count'] = len(recips)
+ msgdata['deliver_until'] = deliver_until
+ msgdata['recips'] = recips
+ self.__retryq.enqueue(msg, msgdata)
# We've successfully completed handling of this message
return False
@@ -134,6 +129,9 @@ class OutgoingRunner(Runner):
self._permfail_counter += 1
if self._permfail_counter < DEAL_WITH_PERMFAILURES_EVERY:
return
+ self._handle_permfailures()
+
+ def _handle_permfailures(self):
# Reset the counter
self._permfail_counter = 0
# And deal with the deferred permanent failures.
@@ -149,3 +147,7 @@ class OutgoingRunner(Runner):
mlist.Save()
finally:
mlist.Unlock()
+
+ def _cleanup(self):
+ self._handle_permfailures()
+ Runner._cleanup(self)