Skip to content

Commit d94deb2

Browse files
committed
internal_name
1 parent a6a73ae commit d94deb2

3 files changed

Lines changed: 224 additions & 175 deletions

File tree

Mailman/Queue/IncomingRunner.py

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -147,65 +147,82 @@ def _dispose(self, mlist, msg, msgdata):
147147
msgid = msg.get('message-id', 'n/a')
148148
filebase = msgdata.get('_filebase', 'unknown')
149149

150-
mailman_log('debug', 'IncomingRunner._dispose: Starting to process incoming message %s (file: %s) for list %s',
151-
msgid, filebase, mlist.internal_name())
150+
# Ensure we have a MailList object
151+
if isinstance(mlist, str):
152+
try:
153+
mlist = MailList.MailList(mlist, lock=0)
154+
should_unlock = True
155+
except Errors.MMUnknownListError:
156+
mailman_log('error', 'IncomingRunner: Unknown list %s', mlist)
157+
self._shunt.enqueue(msg, msgdata)
158+
return True
159+
else:
160+
should_unlock = False
152161

153-
# Check retry delay and duplicate processing
154-
if not self._check_retry_delay(msgid, filebase):
155-
mailman_log('debug', 'IncomingRunner._dispose: Message %s failed retry delay check, skipping', msgid)
156-
return False
157-
158-
# Make sure we have the most up-to-date state
159162
try:
160-
mlist.Load()
161-
mailman_log('debug', 'IncomingRunner._dispose: Successfully loaded list %s', mlist.internal_name())
162-
except Errors.MMCorruptListDatabaseError as e:
163-
mailman_log('error', 'IncomingRunner._dispose: Failed to load list %s: %s\nTraceback:\n%s',
164-
mlist.internal_name(), str(e), traceback.format_exc())
165-
self._unmark_message_processed(msgid)
166-
return False
167-
except Exception as e:
168-
mailman_log('error', 'IncomingRunner._dispose: Unexpected error loading list %s: %s\nTraceback:\n%s',
169-
mlist.internal_name(), str(e), traceback.format_exc())
170-
self._unmark_message_processed(msgid)
171-
return False
163+
mailman_log('debug', 'IncomingRunner._dispose: Starting to process incoming message %s (file: %s) for list %s',
164+
msgid, filebase, mlist.internal_name())
165+
166+
# Check retry delay and duplicate processing
167+
if not self._check_retry_delay(msgid, filebase):
168+
mailman_log('debug', 'IncomingRunner._dispose: Message %s failed retry delay check, skipping', msgid)
169+
return False
172170

173-
# Validate message type first
174-
msg, success = self._validate_message(msg, msgdata)
175-
if not success:
176-
mailman_log('error', 'IncomingRunner._dispose: Message validation failed for message %s', msgid)
177-
self._unmark_message_processed(msgid)
178-
return False
171+
# Make sure we have the most up-to-date state
172+
try:
173+
mlist.Load()
174+
mailman_log('debug', 'IncomingRunner._dispose: Successfully loaded list %s', mlist.internal_name())
175+
except Errors.MMCorruptListDatabaseError as e:
176+
mailman_log('error', 'IncomingRunner._dispose: Failed to load list %s: %s\nTraceback:\n%s',
177+
mlist.internal_name(), str(e), traceback.format_exc())
178+
self._unmark_message_processed(msgid)
179+
return False
180+
except Exception as e:
181+
mailman_log('error', 'IncomingRunner._dispose: Unexpected error loading list %s: %s\nTraceback:\n%s',
182+
mlist.internal_name(), str(e), traceback.format_exc())
183+
self._unmark_message_processed(msgid)
184+
return False
179185

180-
# Validate message headers
181-
if not msg.get('message-id'):
182-
mailman_log('error', 'IncomingRunner._dispose: Message missing Message-ID header')
183-
self._unmark_message_processed(msgid)
184-
return False
186+
# Validate message type first
187+
msg, success = self._validate_message(msg, msgdata)
188+
if not success:
189+
mailman_log('error', 'IncomingRunner._dispose: Message validation failed for message %s', msgid)
190+
self._unmark_message_processed(msgid)
191+
return False
185192

186-
# Process the message
187-
try:
188-
mailman_log('debug', 'IncomingRunner._dispose: Processing message %s', msgid)
189-
190-
# Check if the message is a command
191-
if self._is_command(msg):
192-
mailman_log('debug', 'IncomingRunner._dispose: Message %s is a command', msgid)
193-
return self._process_command(mlist, msg, msgdata)
194-
195-
# Check if the message is a bounce
196-
if self._is_bounce(msg):
197-
mailman_log('debug', 'IncomingRunner._dispose: Message %s is a bounce', msgid)
198-
return self._process_bounce(mlist, msg, msgdata)
199-
200-
# Process as a regular message
201-
mailman_log('debug', 'IncomingRunner._dispose: Processing message %s as regular message', msgid)
202-
return self._process_regular_message(mlist, msg, msgdata)
193+
# Validate message headers
194+
if not msg.get('message-id'):
195+
mailman_log('error', 'IncomingRunner._dispose: Message missing Message-ID header')
196+
self._unmark_message_processed(msgid)
197+
return False
203198

204-
except Exception as e:
205-
mailman_log('error', 'IncomingRunner._dispose: Error processing message %s: %s\nTraceback:\n%s',
206-
msgid, str(e), traceback.format_exc())
207-
self._unmark_message_processed(msgid)
208-
return False
199+
# Process the message
200+
try:
201+
mailman_log('debug', 'IncomingRunner._dispose: Processing message %s', msgid)
202+
203+
# Check if the message is a command
204+
if self._is_command(msg):
205+
mailman_log('debug', 'IncomingRunner._dispose: Message %s is a command', msgid)
206+
return self._process_command(mlist, msg, msgdata)
207+
208+
# Check if the message is a bounce
209+
if self._is_bounce(msg):
210+
mailman_log('debug', 'IncomingRunner._dispose: Message %s is a bounce', msgid)
211+
return self._process_bounce(mlist, msg, msgdata)
212+
213+
# Process as a regular message
214+
mailman_log('debug', 'IncomingRunner._dispose: Processing message %s as regular message', msgid)
215+
return self._process_regular_message(mlist, msg, msgdata)
216+
217+
except Exception as e:
218+
mailman_log('error', 'IncomingRunner._dispose: Error processing message %s: %s\nTraceback:\n%s',
219+
msgid, str(e), traceback.format_exc())
220+
self._unmark_message_processed(msgid)
221+
return False
222+
223+
finally:
224+
if should_unlock:
225+
mlist.Unlock()
209226

210227
def _is_command(self, msg):
211228
"""Check if the message is a command."""
@@ -307,10 +324,6 @@ def _oneloop(self):
307324
try:
308325
# Dequeue the file
309326
msg, msgdata = self._switchboard.dequeue(filebase)
310-
if msg is None:
311-
continue
312-
313-
mailman_log('info', 'IncomingRunner._oneloop: Successfully dequeued file %s', filebase)
314327

315328
# Process the message
316329
try:
@@ -407,5 +420,4 @@ def _process_admin(self, mlist, msg, msgdata):
407420
except Exception as e:
408421
mailman_log('error', 'IncomingRunner._process_admin: Error processing admin message %s: %s\nTraceback:\n%s',
409422
msgid, str(e), traceback.format_exc())
410-
return False
411-
423+
return False

Mailman/Queue/OutgoingRunner.py

Lines changed: 78 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from Mailman.Queue.Runner import Runner
3838
from Mailman.Queue.Switchboard import Switchboard
3939
from Mailman.Queue.BounceRunner import BounceMixin
40+
from Mailman.List import MailList
4041

4142
# This controls how often _doperiodic() will try to deal with deferred
4243
# permanent failures. It is a count of calls to _doperiodic()
@@ -222,73 +223,90 @@ def _dispose(self, mlist, msg, msgdata):
222223
msgid = msg.get('message-id', 'n/a')
223224
filebase = msgdata.get('_filebase', 'unknown')
224225

225-
mailman_log('debug', 'OutgoingRunner._dispose: Starting to process outgoing message %s (file: %s) for list %s',
226-
msgid, filebase, mlist.internal_name())
226+
# Ensure we have a MailList object
227+
if isinstance(mlist, str):
228+
try:
229+
mlist = MailList.MailList(mlist, lock=0)
230+
should_unlock = True
231+
except Errors.MMUnknownListError:
232+
mailman_log('error', 'OutgoingRunner: Unknown list %s', mlist)
233+
self._shunt.enqueue(msg, msgdata)
234+
return True
235+
else:
236+
should_unlock = False
227237

228-
# Check retry delay and duplicate processing
229-
if not self._check_retry_delay(msgid, filebase):
230-
mailman_log('debug', 'OutgoingRunner._dispose: Message %s failed retry delay check, skipping', msgid)
231-
return False
232-
233-
# Make sure we have the most up-to-date state
234238
try:
235-
mlist.Load()
236-
mailman_log('debug', 'OutgoingRunner._dispose: Successfully loaded list %s', mlist.internal_name())
237-
except Errors.MMCorruptListDatabaseError as e:
238-
mailman_log('error', 'OutgoingRunner._dispose: Failed to load list %s: %s\nTraceback:\n%s',
239-
mlist.internal_name(), str(e), traceback.format_exc())
240-
self._unmark_message_processed(msgid)
241-
return False
242-
except Exception as e:
243-
mailman_log('error', 'OutgoingRunner._dispose: Unexpected error loading list %s: %s\nTraceback:\n%s',
244-
mlist.internal_name(), str(e), traceback.format_exc())
245-
self._unmark_message_processed(msgid)
246-
return False
239+
mailman_log('debug', 'OutgoingRunner._dispose: Starting to process outgoing message %s (file: %s) for list %s',
240+
msgid, filebase, mlist.internal_name())
241+
242+
# Check retry delay and duplicate processing
243+
if not self._check_retry_delay(msgid, filebase):
244+
mailman_log('debug', 'OutgoingRunner._dispose: Message %s failed retry delay check, skipping', msgid)
245+
return False
247246

248-
# Validate message type first
249-
msg, success = self._validate_message(msg, msgdata)
250-
if not success:
251-
mailman_log('error', 'OutgoingRunner._dispose: Message validation failed for message %s', msgid)
252-
self._unmark_message_processed(msgid)
253-
return False
247+
# Make sure we have the most up-to-date state
248+
try:
249+
mlist.Load()
250+
mailman_log('debug', 'OutgoingRunner._dispose: Successfully loaded list %s', mlist.internal_name())
251+
except Errors.MMCorruptListDatabaseError as e:
252+
mailman_log('error', 'OutgoingRunner._dispose: Failed to load list %s: %s\nTraceback:\n%s',
253+
mlist.internal_name(), str(e), traceback.format_exc())
254+
self._unmark_message_processed(msgid)
255+
return False
256+
except Exception as e:
257+
mailman_log('error', 'OutgoingRunner._dispose: Unexpected error loading list %s: %s\nTraceback:\n%s',
258+
mlist.internal_name(), str(e), traceback.format_exc())
259+
self._unmark_message_processed(msgid)
260+
return False
254261

255-
# Validate message headers
256-
if not msg.get('message-id'):
257-
mailman_log('error', 'OutgoingRunner._dispose: Message missing Message-ID header')
258-
self._unmark_message_processed(msgid)
259-
return False
262+
# Validate message type first
263+
msg, success = self._validate_message(msg, msgdata)
264+
if not success:
265+
mailman_log('error', 'OutgoingRunner._dispose: Message validation failed for message %s', msgid)
266+
self._unmark_message_processed(msgid)
267+
return False
260268

261-
# Process the outgoing message
262-
try:
263-
mailman_log('debug', 'OutgoingRunner._dispose: Processing outgoing message %s', msgid)
264-
265-
# Get message type and recipient
266-
msgtype = msgdata.get('_msgtype', 'unknown')
267-
recipient = msgdata.get('recipient', 'unknown')
268-
269-
mailman_log('debug', 'OutgoingRunner._dispose: Message %s is type %s for recipient %s',
270-
msgid, msgtype, recipient)
271-
272-
# Process based on message type
273-
if msgtype == 'bounce':
274-
success = self._process_bounce(mlist, msg, msgdata)
275-
elif msgtype == 'admin':
276-
success = self._process_admin(mlist, msg, msgdata)
277-
else:
278-
success = self._process_regular(mlist, msg, msgdata)
279-
280-
if success:
281-
mailman_log('debug', 'OutgoingRunner._dispose: Successfully processed outgoing message %s', msgid)
282-
return True
283-
else:
284-
mailman_log('error', 'OutgoingRunner._dispose: Failed to process outgoing message %s', msgid)
269+
# Validate message headers
270+
if not msg.get('message-id'):
271+
mailman_log('error', 'OutgoingRunner._dispose: Message missing Message-ID header')
272+
self._unmark_message_processed(msgid)
285273
return False
286274

287-
except Exception as e:
288-
mailman_log('error', 'OutgoingRunner._dispose: Error processing outgoing message %s: %s\nTraceback:\n%s',
289-
msgid, str(e), traceback.format_exc())
290-
self._unmark_message_processed(msgid)
291-
return False
275+
# Process the outgoing message
276+
try:
277+
mailman_log('debug', 'OutgoingRunner._dispose: Processing outgoing message %s', msgid)
278+
279+
# Get message type and recipient
280+
msgtype = msgdata.get('_msgtype', 'unknown')
281+
recipient = msgdata.get('recipient', 'unknown')
282+
283+
mailman_log('debug', 'OutgoingRunner._dispose: Message %s is type %s for recipient %s',
284+
msgid, msgtype, recipient)
285+
286+
# Process based on message type
287+
if msgtype == 'bounce':
288+
success = self._process_bounce(mlist, msg, msgdata)
289+
elif msgtype == 'admin':
290+
success = self._process_admin(mlist, msg, msgdata)
291+
else:
292+
success = self._process_regular(mlist, msg, msgdata)
293+
294+
if success:
295+
mailman_log('debug', 'OutgoingRunner._dispose: Successfully processed outgoing message %s', msgid)
296+
return True
297+
else:
298+
mailman_log('error', 'OutgoingRunner._dispose: Failed to process outgoing message %s', msgid)
299+
return False
300+
301+
except Exception as e:
302+
mailman_log('error', 'OutgoingRunner._dispose: Error processing outgoing message %s: %s\nTraceback:\n%s',
303+
msgid, str(e), traceback.format_exc())
304+
self._unmark_message_processed(msgid)
305+
return False
306+
307+
finally:
308+
if should_unlock:
309+
mlist.Unlock()
292310

293311
def _process_bounce(self, mlist, msg, msgdata):
294312
"""Process a bounce message."""

0 commit comments

Comments
 (0)