athoune / imapidle

Handling IMAP IDLE command with plain old Python.
MIT License
33 stars 10 forks source link

Handle empty server response when logged off due to inactivity #3

Open bkg opened 11 years ago

bkg commented 11 years ago

I am seeing an error when idling on a gmail inbox and the server logs the user out after a period of time. From a close look at the IDLE spec, this is legitimate behavior. Specifically, the stack trace is:

Traceback (most recent call last):
  File "imapidle/src/imapidle.py", line 64, in <module>
    for uid, msg in mbox.idle():
  File "imapidle/src/imapidle.py", line 21, in idle
    uid, message = resp[2:-2].split(' ')
ValueError: need more than 1 value to unpack

This change adds error handling for the above case. I have been able to idle on a gmail account for multiple days now.

BTW, thanks for this, it has proven to be very useful!