Skip to content

Commit 26c62d3

Browse files
committed
update
1 parent 1e59f3e commit 26c62d3

2 files changed

Lines changed: 25 additions & 65 deletions

File tree

Mailman/Queue/VirginRunner.py

Lines changed: 18 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
from Mailman import MailList
3030
import time
3131
import traceback
32+
from Mailman import Errors
3233

3334

34-
class VirginRunner(IncomingRunner):
35+
class VirginRunner(Runner):
3536
QDIR = mm_cfg.VIRGINQUEUE_DIR
3637
# Override the minimum retry delay for virgin messages
3738
MIN_RETRY_DELAY = 60 # 1 minute minimum delay between retries
@@ -116,69 +117,25 @@ def _check_retry_delay(self, msgid, filebase):
116117
msgid, str(e))
117118
return False
118119

119-
def _dispose(self, listname, msg, msgdata):
120+
def _dispose(self, mlist, msg, msgdata):
121+
"""Process a virgin message."""
120122
msgid = msg.get('message-id', 'n/a')
121123
filebase = msgdata.get('_filebase', 'unknown')
122124

123-
# Check retry delay but don't shunt on timeout
124-
if not self._check_retry_delay(msgid, filebase):
125-
mailman_log('info', 'VirginRunner: Message %s (file: %s) not ready for processing yet, will retry',
126-
msgid, filebase)
127-
return 1 # Return 1 to indicate we should keep trying
128-
129-
try:
130-
# Get the MailList object
131-
try:
132-
mailman_log('debug', 'VirginRunner: Getting MailList object for list %s', listname)
133-
mlist = MailList.MailList(listname, lock=0)
134-
mailman_log('debug', 'VirginRunner: Successfully got MailList object for list %s', listname)
135-
except Exception as e:
136-
mailman_log('error', 'Failed to get MailList object for list %s: %s',
137-
listname, str(e))
138-
return 1 # Return 1 to keep trying instead of shunting
139-
140-
# Log start of processing
141-
mailman_log('info', 'VirginRunner: Starting to process virgin message %s (file: %s) for list %s',
142-
msgid, filebase, mlist.internal_name())
143-
144-
# We need to fasttrack this message through any handlers that touch
145-
# it. E.g. especially CookHeaders.
146-
msgdata['_fasttrack'] = 1
147-
mailman_log('debug', 'VirginRunner: Set _fasttrack flag for message %s', msgid)
148-
149-
# Get the pipeline and log it
150-
pipeline = self._get_pipeline(mlist, msg, msgdata)
151-
mailman_log('debug', 'VirginRunner: Pipeline for message %s: %s', msgid, pipeline)
152-
153-
# Process through the pipeline
154-
mailman_log('debug', 'VirginRunner: Starting pipeline processing for message %s', msgid)
155-
try:
156-
result = IncomingRunner._dispose(self, mlist, msg, msgdata)
157-
mailman_log('debug', 'VirginRunner: Pipeline processing completed for message %s with result: %s', msgid, result)
158-
except Exception as e:
159-
mailman_log('error', 'VirginRunner: Pipeline processing failed for message %s: %s', msgid, str(e))
160-
mailman_log('error', 'VirginRunner: Pipeline processing traceback:\n%s', traceback.format_exc())
161-
raise
162-
163-
# Log successful completion
164-
mailman_log('info', 'VirginRunner: Successfully processed virgin message %s (file: %s) for list %s',
165-
msgid, filebase, mlist.internal_name())
166-
return result
167-
except Exception as e:
168-
# Enhanced error logging with more context
169-
mailman_log('error', 'Error processing virgin message %s for list %s: %s',
170-
msgid, listname, str(e))
171-
mailman_log('error', 'Message details:')
172-
mailman_log('error', ' Message ID: %s', msgid)
173-
mailman_log('error', ' From: %s', msg.get('from', 'unknown'))
174-
mailman_log('error', ' To: %s', msg.get('to', 'unknown'))
175-
mailman_log('error', ' Subject: %s', msg.get('subject', '(no subject)'))
176-
mailman_log('error', ' Message type: %s', type(msg).__name__)
177-
mailman_log('error', ' Message data: %s', str(msgdata))
178-
mailman_log('error', 'Traceback:\n%s', traceback.format_exc())
179-
180-
# Don't remove from processed messages on error, let it retry
181-
return 1 # Return 1 to keep trying instead of shunting
125+
mailman_log('debug', 'VirginRunner._dispose: Starting to process virgin message %s (file: %s)',
126+
msgid, filebase)
127+
128+
# Get the IncomingRunner class
129+
from Mailman.Queue import get_incoming_runner
130+
IncomingRunner = get_incoming_runner()
131+
132+
# Process the message using IncomingRunner's _dispose method
133+
result = IncomingRunner._dispose(self, mlist, msg, msgdata)
134+
135+
mailman_log('debug', 'VirginRunner._dispose: Finished processing virgin message %s (file: %s)',
136+
msgid, filebase)
137+
138+
return result
182139

183140
def _get_pipeline(self, mlist, msg, msgdata):
184141
# It's okay to hardcode this, since it'll be the same for all

Mailman/Queue/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@
4242
from Mailman.Queue.CommandRunner import CommandRunner
4343
from Mailman.Queue.ArchRunner import ArchRunner
4444

45-
# Import IncomingRunner and VirginRunner last to avoid circular imports
46-
from Mailman.Queue.IncomingRunner import IncomingRunner
45+
# Import VirginRunner last to avoid circular imports
4746
from Mailman.Queue.VirginRunner import VirginRunner
4847

49-
# Define NewsRunner as a lazy import to avoid circular dependencies
48+
# Define lazy imports to avoid circular dependencies
5049
def get_news_runner():
5150
from Mailman.Queue.NewsRunner import NewsRunner
5251
return NewsRunner
5352

53+
def get_incoming_runner():
54+
from Mailman.Queue.IncomingRunner import IncomingRunner
55+
return IncomingRunner
56+
5457
__all__ = [
5558
'Runner',
5659
'Switchboard',
@@ -60,7 +63,7 @@ def get_news_runner():
6063
'RetryRunner',
6164
'CommandRunner',
6265
'ArchRunner',
63-
'IncomingRunner',
6466
'VirginRunner',
6567
'get_news_runner',
68+
'get_incoming_runner',
6669
]

0 commit comments

Comments
 (0)