请参阅python-imap-idle-with-imaplib2中的示例和参考。该模块涉及线程,您应注意事件同步。
该示例建议与事件同步,并将邮件处理留给阅读器:
# The method that gets called when a new email arrives. # Replace it with something better.def dosync(self): print "Got an event!"
从问题中暗示,“更好的东西”可以是:
# Replaced with something better.def dosync(self): print "Got an event!" res = self.M.recent() print res



