|
40 | 40 | class Runner: |
41 | 41 | QDIR = None |
42 | 42 | SLEEPTIME = mm_cfg.QRUNNER_SLEEP_TIME |
| 43 | + MIN_RETRY_DELAY = 300 # 5 minutes minimum delay between retries |
43 | 44 |
|
44 | 45 | # Message tracking configuration - can be overridden by subclasses |
45 | 46 | _track_messages = False # Whether to track processed messages |
@@ -74,6 +75,10 @@ def __init__(self, slice=None, numslices=1): |
74 | 75 | self._last_cleanup = time.time() |
75 | 76 | self._cleanup_interval = 3600 |
76 | 77 |
|
| 78 | + # Initialize error tracking attributes |
| 79 | + self._last_error_time = 0 |
| 80 | + self._error_count = 0 |
| 81 | + |
77 | 82 | syslog('debug', 'Runner: Initialization complete') |
78 | 83 | except Exception as e: |
79 | 84 | syslog('error', 'Runner: Initialization failed: %s\nTraceback:\n%s', |
@@ -112,17 +117,32 @@ def run(self): |
112 | 117 | # subprocesses we've created and do any other necessary cleanups. |
113 | 118 | self._cleanup() |
114 | 119 |
|
115 | | - def log_error(self, error_type, error, msg=None, mlist=None, **context): |
116 | | - """Structured error logging with context.""" |
117 | | - context.update({ |
| 120 | + def log_error(self, error_type, error_msg, **kwargs): |
| 121 | + """Log an error with the given type and message. |
| 122 | + |
| 123 | + Args: |
| 124 | + error_type: A string identifying the type of error |
| 125 | + error_msg: The error message to log |
| 126 | + **kwargs: Additional context to include in the log message |
| 127 | + """ |
| 128 | + context = { |
118 | 129 | 'runner': self.__class__.__name__, |
119 | | - 'list': mlist.internal_name() if mlist else 'N/A', |
120 | | - 'msg_id': msg.get('message-id', 'N/A') if msg else 'N/A', |
121 | 130 | 'error_type': error_type, |
122 | | - 'error': str(error) |
123 | | - }) |
124 | | - syslog('error', '%(runner)s: %(error_type)s - list: %(list)s, msg: %(msg_id)s, error: %(error)s', |
125 | | - context) |
| 131 | + 'error_msg': error_msg, |
| 132 | + } |
| 133 | + context.update(kwargs) |
| 134 | + |
| 135 | + # Format the error message |
| 136 | + msg_parts = ['%s: %s' % (error_type, error_msg)] |
| 137 | + if 'msg' in context: |
| 138 | + msg_parts.append('Message-ID: %s' % context['msg'].get('message-id', 'unknown')) |
| 139 | + if 'listname' in context: |
| 140 | + msg_parts.append('List: %s' % context['listname']) |
| 141 | + if 'traceback' in context: |
| 142 | + msg_parts.append('Traceback:\n%s' % context['traceback']) |
| 143 | + |
| 144 | + # Log the error |
| 145 | + syslog('error', ' '.join(msg_parts)) |
126 | 146 |
|
127 | 147 | def log_warning(self, warning_type, msg=None, mlist=None, **context): |
128 | 148 | """Structured warning logging with context.""" |
@@ -196,7 +216,7 @@ def _oneloop(self): |
196 | 216 |
|
197 | 217 | # Process the message |
198 | 218 | try: |
199 | | - self._dopost(msg, msgdata) |
| 219 | + self._onefile(msg, msgdata) |
200 | 220 | except Exception as e: |
201 | 221 | syslog('error', 'Runner._oneloop: Error processing message %s: %s', filebase, str(e)) |
202 | 222 | continue |
|
0 commit comments