From c27e4dff80bc591170c0a8a1f0b24e9ee9eee2ba Mon Sep 17 00:00:00 2001 From: Andreas Knuth Date: Sat, 10 Jan 2026 18:23:55 -0600 Subject: [PATCH] guard --- unified-worker/unified_worker.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/unified-worker/unified_worker.py b/unified-worker/unified_worker.py index f027be3..6801115 100644 --- a/unified-worker/unified_worker.py +++ b/unified-worker/unified_worker.py @@ -919,9 +919,9 @@ def process_message(domain: str, message: dict, receive_count: int) -> bool: parsed = BytesParser(policy=SMTPPolicy).parsebytes(raw_bytes) subject = parsed.get('Subject', '(no subject)') - # Bounce Header umschreiben + # Bounce Header umschreiben (setzt auch is_bounce intern) + is_bounce = is_ses_bounce_notification(parsed) parsed, modified = apply_bounce_logic(parsed, subject, worker_name) - is_bounce = is_ses_bounce_notification(BytesParser(policy=SMTPPolicy).parsebytes(raw_bytes)) if modified: log(" ✨ Bounce detected & headers rewritten via DynamoDB", 'INFO', worker_name) @@ -1268,7 +1268,16 @@ def start_health_server(worker: UnifiedWorker): # ENTRY POINT # ============================================ +# Global flag to prevent double execution +_worker_started = False + def main(): + global _worker_started + if _worker_started: + log("⚠ Worker already started, ignoring duplicate call", 'WARNING') + return + _worker_started = True + worker = UnifiedWorker() def signal_handler(signum, frame): @@ -1311,4 +1320,4 @@ def main(): worker.start() if __name__ == '__main__': - main() + main() \ No newline at end of file