How to tell whether imaplib2 idle response resulted from timeout

百般思念 提交于 2019-12-04 17:47:24

Piers Lauder (author of imaplib2) just answered this question on the imaplib2-devel mailing list. He said:

I think the way to test if an IDLE has timed out is to execute:

instance.response('IDLE')

which will return:

('IDLE', ['TIMEOUT'])

if the reason that the idle returned as a timeout, rather than something else (such as ('IDLE', [None])).

I agree that this should be documented, so I'll fix the imaplib2.html document

You'll have to manually check for new messages each time you get this response. You can store the UIDs of messages in a list and compare new UIDs with it upon each callback. This way you can easily tell if there are new messages or a timeout.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!