classification
Title: Implementation of IMAP IDLE in imaplib?
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Shay.Rojansky, eric.smith, pierslauder, r.david.murray, terry.reedy
Priority: normal Keywords:

Created on 2011-02-18 20:36 by Shay.Rojansky, last changed 2011-02-25 19:47 by r.david.murray.

Messages (3)
msg128814 - (view) Author: Shay Rojansky (Shay.Rojansky) Date: 2011-02-18 20:36
IMAP IDLE support is not implemented in the current imaplib. A "drop-in" replacement called imaplib2 exists (), but uses internally managed threads - a heavy solution that is not always appropriate (e.g. when handling many IMAP accounts an asynchronous approach would be more efficient)

I am about to start implementation of an asynchronous select()-compatible approach, and was wondering if there has been any discussion over IDLE, any specific reasons it hasn't been implemented and if eventual integration into imaplib would be a desirable thing.

Proposed approach:
* Addition of a new state 'IDLE'
* Addition of an idle() method to class IMAP4, which issues the IDLE command to the server and returns immediately. At this point we enter the IDLE state, in which no normal IMAP commands may be issued.
* Users can now select() or poll() the socket as they wish
* A method can be called to retrieve any untagged responses (e.g. EXISTS) that have arrived since entering the IDLE state. The function returns immediately and does not modify the state.
* To end the IDLE state, the user calls a method (done()?) which resumes the previous state.

Would appreciate any sort of feedback...
msg129405 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-02-25 19:39
imaplib has no particular maintainer and I know little about it.
Doc says it implements 'a large subset of the IMAP4rev1 client protocol as defined in RFC 2060." I do not remember any discussion on pydev, over the last several years, about imaplib. I presume just the subset was chosen because of some combination of necessity and feasibility, as judged by the implementors.  Hence the complement, the unimplemented subset, would be 'not done' rather than 'not wanted'. If your proposed new feature, an IDLE command, is part of this complement, then I would assume that a patch would, in principle, be acceptable.

I cannot comment on your particular proposal, but I hope the above helps as far as it goes.
msg129407 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-02-25 19:47
I just wound up doing a bit of research on this for other reasons.  Piers Lauder was the original author of the imaplib module, and he is (as far as I can tell) currently maintaining an imaplib2 module that does support IDLE (but not, I think, python3).  But it does IDLE (and other things) via threads, and in the email I found announcing it he didn't think it was suitable for stdlib inclusion (because of the threading).  Piers hasn't contributed to core in quite a while as far as I can tell, but he was active in a bug report back in 2008 according to google, so I thought I'd add him to nosy and see if he has time for an opinion.
History
Date User Action Args
2011-02-25 19:47:37r.david.murraysetnosy: + r.david.murray, pierslauder, eric.smith
messages: + msg129407
2011-02-25 19:40:00terry.reedysetversions: + Python 3.3
nosy: + terry.reedy

messages: + msg129405

stage: test needed
2011-02-18 20:36:10Shay.Rojanskycreate