From 11cf6f8ba6e8663e51b30b00603f8d6d063208c2 Mon Sep 17 00:00:00 2001 From: Sean Whalen Date: Sun, 30 Jun 2019 19:56:11 -0400 Subject: [PATCH] Revert "Add IMAP message download timeout" This reverts commit 6a27f41de1c1f6bc9bd2cf9b8eca62ed6653587e. --- parsedmarc/__init__.py | 27 +++++++++------------------ requirements.txt | 1 - 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/parsedmarc/__init__.py b/parsedmarc/__init__.py index c4664858..8656ba01 100644 --- a/parsedmarc/__init__.py +++ b/parsedmarc/__init__.py @@ -32,7 +32,6 @@ import xmltodict import imapclient import imapclient.exceptions import mailparser -import timeout_decorator from parsedmarc.utils import get_base_domain, get_ip_address_info from parsedmarc.utils import is_outlook_msg, convert_outlook_msg @@ -949,20 +948,6 @@ def get_dmarc_reports_from_inbox(host=None, server_capabilities = get_imap_capabilities(server) move_supported = "MOVE" in server_capabilities - @timeout_decorator.timeout(5) - def fetch_message(msg_uid): - raw_msg = server.fetch(msg_uid, - ["RFC822"])[msg_uid] - msg_keys = [b'RFC822', b'BODY[NULL]', b'BODY[]'] - msg_key = '' - for key in msg_keys: - if key in raw_msg.keys(): - msg_key = key - break - raw_msg = raw_msg[msg_key] - - return raw_msg - def delete_messages(msg_uids): logger.debug("Deleting message UID(s) {0}".format(",".join( str(uid) for uid in msg_uids))) @@ -1043,10 +1028,16 @@ def get_dmarc_reports_from_inbox(host=None, )) try: try: - raw_msg = fetch_message(msg_uid) + raw_msg = server.fetch(msg_uid, + ["RFC822"])[msg_uid] + msg_keys = [b'RFC822', b'BODY[NULL]', b'BODY[]'] + msg_key = '' + for key in msg_keys: + if key in raw_msg.keys(): + msg_key = key + break + raw_msg = raw_msg[msg_key] - except timeout_decorator.timeout_decorator.TimeoutError: - logger.debug("Download timed out. Retrying...") except (ConnectionResetError, socket.error, TimeoutError, imapclient.exceptions.IMAPClientError) as error: diff --git a/requirements.txt b/requirements.txt index de9ac0bd..f1d9df21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,6 @@ dateparser>=0.7.1 elasticsearch>=6.3.1,<7.0.0 elasticsearch-dsl>=6.3.1,<7.0.0 kafka-python>=1.4.4 -timeout-decorator>=0.4.1 nose pygments flake8