From d2a0f8530344a09eae33f749a7365d9dbe6eeb78 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Mar 2026 19:12:46 -0400 Subject: [PATCH] Ensure SIGHUP never triggers a new email batch across all watch() implementations (#704) * Initial plan * Ensure SIGHUP never starts a new email batch in any watch() implementation Co-authored-by: seanthegeek <44679+seanthegeek@users.noreply.github.com> Agent-Logs-Url: https://github.com/domainaware/parsedmarc/sessions/45d5be30-8f6b-4200-9bdd-15c655033f17 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: seanthegeek <44679+seanthegeek@users.noreply.github.com> --- parsedmarc/mail/graph.py | 2 ++ parsedmarc/mail/imap.py | 2 ++ parsedmarc/mail/maildir.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/parsedmarc/mail/graph.py b/parsedmarc/mail/graph.py index 513ece3..a2f5c0e 100644 --- a/parsedmarc/mail/graph.py +++ b/parsedmarc/mail/graph.py @@ -284,6 +284,8 @@ class MSGraphConnection(MailboxConnection): if should_reload and should_reload(): return sleep(check_timeout) + if should_reload and should_reload(): + return check_callback(self) @lru_cache(maxsize=10) diff --git a/parsedmarc/mail/imap.py b/parsedmarc/mail/imap.py index d9d8bb4..b084bd9 100644 --- a/parsedmarc/mail/imap.py +++ b/parsedmarc/mail/imap.py @@ -94,6 +94,8 @@ class IMAPConnection(MailboxConnection): check_callback(self) while True: + if should_reload and should_reload(): + return try: IMAPClient( host=self._client.host, diff --git a/parsedmarc/mail/maildir.py b/parsedmarc/mail/maildir.py index 255cea0..20b08a0 100644 --- a/parsedmarc/mail/maildir.py +++ b/parsedmarc/mail/maildir.py @@ -65,6 +65,8 @@ class MaildirConnection(MailboxConnection): def watch(self, check_callback, check_timeout, should_reload=None): while True: + if should_reload and should_reload(): + return try: check_callback(self) except Exception as e: