|
29 | 29 | from Mailman import MailList |
30 | 30 | import time |
31 | 31 | import traceback |
| 32 | +from Mailman import Errors |
32 | 33 |
|
33 | 34 |
|
34 | | -class VirginRunner(IncomingRunner): |
| 35 | +class VirginRunner(Runner): |
35 | 36 | QDIR = mm_cfg.VIRGINQUEUE_DIR |
36 | 37 | # Override the minimum retry delay for virgin messages |
37 | 38 | MIN_RETRY_DELAY = 60 # 1 minute minimum delay between retries |
@@ -116,69 +117,25 @@ def _check_retry_delay(self, msgid, filebase): |
116 | 117 | msgid, str(e)) |
117 | 118 | return False |
118 | 119 |
|
119 | | - def _dispose(self, listname, msg, msgdata): |
| 120 | + def _dispose(self, mlist, msg, msgdata): |
| 121 | + """Process a virgin message.""" |
120 | 122 | msgid = msg.get('message-id', 'n/a') |
121 | 123 | filebase = msgdata.get('_filebase', 'unknown') |
122 | 124 |
|
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 |
182 | 139 |
|
183 | 140 | def _get_pipeline(self, mlist, msg, msgdata): |
184 | 141 | # It's okay to hardcode this, since it'll be the same for all |
|
0 commit comments