mirror of
https://github.com/craigerl/aprsd.git
synced 2025-02-03 09:44:15 -05:00
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()
|
||||
|
||||
|
||||
def check_email_thread():
|
||||
# print "Email thread disabled."
|
||||
# return
|
||||
def check_email_thread(check_email_delay):
|
||||
|
||||
LOG.debug("Starting Email thread")
|
||||
# how do we skip first run?
|
||||
threading.Timer(55, check_email_thread).start()
|
||||
while True:
|
||||
# threading.Timer(55, check_email_thread).start()
|
||||
|
||||
time.sleep(check_email_delay)
|
||||
|
||||
shortcuts = CONFIG['shortcuts']
|
||||
# swap key/value
|
||||
@ -259,10 +258,9 @@ def check_email_thread():
|
||||
server.login(CONFIG['imap']['login'], CONFIG['imap']['password'])
|
||||
except Exception:
|
||||
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')
|
||||
|
||||
messages = server.search(['SINCE', today])
|
||||
@ -300,7 +298,8 @@ def check_email_thread():
|
||||
server.remove_flags(msgid, [SEEN])
|
||||
|
||||
server.logout()
|
||||
# end check_email()
|
||||
|
||||
# end check_email()
|
||||
|
||||
|
||||
def send_ack_thread(tocall, ack, retry_count):
|
||||
@ -498,7 +497,9 @@ def main(args=args):
|
||||
|
||||
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")
|
||||
while True:
|
||||
|
Loading…
Reference in New Issue
Block a user