Detecting other IMAP-errors. Adding short sleep to avoid hammering the IMAP-server on error

This commit is contained in:
Ola Thoresen
2021-01-20 19:56:15 +01:00
parent b43a622f9e
commit be8395dbe3
+5
View File
@@ -8,6 +8,7 @@ import shutil
import xml.parsers.expat as expat
import json
from datetime import datetime
from time import sleep
from collections import OrderedDict
from io import BytesIO, StringIO
from gzip import GzipFile
@@ -1234,6 +1235,10 @@ def watch_inbox(host, username, password, callback, port=None, ssl=True,
idle_timeout=idle_timeout)
except (timeout, IMAPClientError):
logger.warning("IMAP connection timeout. Reconnecting...")
sleep(5)
except Exception as e:
logger.warning("IMAP connection error. {0}. Reconnecting...".format(e))
sleep(5)
def save_output(results, output_directory="output"):