mirror of https://github.com/craigerl/aprsd.git
fix check_email_thread to do proper threading, take delay as arg
This commit is contained in:
parent
f175f7e6e3
commit
e171e16854
|
@ -232,13 +232,12 @@ def resend_email(count, fromcall):
|
||||||
# end resend_email()
|
# end resend_email()
|
||||||
|
|
||||||
|
|
||||||
def check_email_thread():
|
def check_email_thread(check_email_delay):
|
||||||
# print "Email thread disabled."
|
|
||||||
# return
|
|
||||||
|
|
||||||
LOG.debug("Starting Email thread")
|
while True:
|
||||||
# how do we skip first run?
|
# threading.Timer(55, check_email_thread).start()
|
||||||
threading.Timer(55, check_email_thread).start()
|
|
||||||
|
time.sleep(check_email_delay)
|
||||||
|
|
||||||
shortcuts = CONFIG['shortcuts']
|
shortcuts = CONFIG['shortcuts']
|
||||||
# swap key/value
|
# swap key/value
|
||||||
|
@ -259,10 +258,9 @@ def check_email_thread():
|
||||||
server.login(CONFIG['imap']['login'], CONFIG['imap']['password'])
|
server.login(CONFIG['imap']['login'], CONFIG['imap']['password'])
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("Failed to login with IMAP server")
|
LOG.exception("Failed to login with IMAP server")
|
||||||
return
|
#return
|
||||||
|
continue
|
||||||
|
|
||||||
# if 'gmail' in CONFIG['imap']['host'].lower():
|
|
||||||
# server.select_folder('INBOX')
|
|
||||||
server.select_folder('INBOX')
|
server.select_folder('INBOX')
|
||||||
|
|
||||||
messages = server.search(['SINCE', today])
|
messages = server.search(['SINCE', today])
|
||||||
|
@ -300,6 +298,7 @@ def check_email_thread():
|
||||||
server.remove_flags(msgid, [SEEN])
|
server.remove_flags(msgid, [SEEN])
|
||||||
|
|
||||||
server.logout()
|
server.logout()
|
||||||
|
|
||||||
# end check_email()
|
# end check_email()
|
||||||
|
|
||||||
|
|
||||||
|
@ -498,7 +497,9 @@ def main(args=args):
|
||||||
|
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
check_email_thread() # start email reader thread
|
check_email_delay = 60 # initial email check interval
|
||||||
|
checkemailthread = threading.Thread(target=check_email_thread, args=(check_email_delay, )) # args must be tuple
|
||||||
|
checkemailthread.start()
|
||||||
|
|
||||||
LOG.info("Start main loop")
|
LOG.info("Start main loop")
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue