我正在编写一个python applet来监视我工作场所的电子邮箱的未读数量,当我尝试在applet闲置大约10分钟后尝试使用任何imaplib方法时遇到了EOF错误.一切正常,直到applet活着超过10分钟.
这是imaplib对象的相关代码.
conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
def loginIMAP (imapObj):
# Login to Helpdesk Google Apps Email account using encryption
imapObj.login(base64.b64decode("usrEncryption"), base64.b64decode("pwdEncrytion"))
return(getUnread(imapObj))
def closeIMAP (imapObj):
imapObj.logout()
def getUnread (imapObj):
# Check connection status OK
try:
uc0 = int(re.search("UNSEEN (\d+)", imapObj.status("INBOX", "(UNSEEN)")[1][0]).group(1))
uc1 = int(re.search("UNSEEN (\d+)", imapObj.status("A box 1", "(UNSEEN)")[1][0]).group(1))
uc2 = int(re.search("UNSEEN (\d+)", imapObj.status("A box 2", "(UNSEEN)")[1][0]).group(1))
except:
print "Shit's all disconnected n stuff"
loginIMAP(conn)
unreadCount = [(uc0-(uc1+uc2)),uc1,uc2]
if unreadCount[0] < 0:
unreadCount[0]=0
return unreadCount
Run Code Online (Sandbox Code Playgroud)
usrEncryption并且pwdEncryption只是我屏蔽了u/p所以我们的服务台登录并非全部公开. …