mirror of https://github.com/craigerl/aprsd.git
EmailThread was exiting because of IMAP timeout, added exceptions for this
This commit is contained in:
parent
db2b537317
commit
47135c6086
|
@ -34,8 +34,8 @@ def _imap_connect():
|
|||
ssl=use_ssl,
|
||||
timeout=30,
|
||||
)
|
||||
except Exception:
|
||||
LOG.error("Failed to connect IMAP server")
|
||||
except Exception as e:
|
||||
LOG.error("Failed to connect IMAP server", e)
|
||||
return
|
||||
|
||||
try:
|
||||
|
@ -421,7 +421,7 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||
try:
|
||||
server = _imap_connect()
|
||||
except Exception as e:
|
||||
LOG.exception("Failed to get IMAP server Can't check email.", e)
|
||||
LOG.exception("IMAP failed to connect.", e)
|
||||
|
||||
LOG.debug("Tried _imap_connect")
|
||||
|
||||
|
@ -429,10 +429,15 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||
continue
|
||||
|
||||
LOG.debug("Try Server.search since today.")
|
||||
try:
|
||||
messages = server.search(["SINCE", today])
|
||||
except Exception as e:
|
||||
LOG.exception("IMAP failed to search for messages since today.", e)
|
||||
continue
|
||||
LOG.debug("{} messages received today".format(len(messages)))
|
||||
|
||||
LOG.debug("Try Server.fetch.")
|
||||
try:
|
||||
for msgid, data in server.fetch(messages, ["ENVELOPE"]).items():
|
||||
envelope = data[b"ENVELOPE"]
|
||||
LOG.debug(
|
||||
|
@ -483,10 +488,16 @@ class APRSDEmailThread(threads.APRSDThread):
|
|||
server.remove_flags(msgid, [imapclient.SEEN])
|
||||
# check email more often since we just received an email
|
||||
check_email_delay = 60
|
||||
except Exception as e:
|
||||
LOG.exception("IMAP failed to fetch/flag messages: ", e)
|
||||
# reset clock
|
||||
LOG.debug("Done looping over Server.fetch, logging out.")
|
||||
past = datetime.datetime.now()
|
||||
try:
|
||||
server.logout()
|
||||
except Exception as e:
|
||||
LOG.exception("IMAP failed to logout: ", e)
|
||||
continue
|
||||
else:
|
||||
# We haven't hit the email delay yet.
|
||||
# LOG.debug("Delta({}) < {}".format(now - past, check_email_delay))
|
||||
|
|
Loading…
Reference in New Issue