[Twisted-Python] twisted.mail.imap4.IMAP4Client.fetchMessage always throws exception
Hi, I've installed Twisted 15.3.0 on Ubuntu 14.04LTS. Excellent work but there's one problem bothering me for a long time: twisted.mail.imap4.IMAP4Client.fetchMessage always throws exception and the exception occured at random, e.g. somtimes the exception occured when the program read the 120th mail, sometimes it occured at the 150th or 200th mail. The traceback of the exception is as follows: Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/log.py", line 101, in callWithLogger return callWithContext({"system": lp}, func, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/log.py", line 84, in callWithContext return context.call({ILogContext: newCtx}, func, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/context.py", line 81, in callWithContext return func(*args,**kw) --- <exception caught here> --- File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/internet/posixbase.py", line 597, in _doReadOrWrite why = selectable.doRead() File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/internet/tcp.py", line 209, in doRead return self._dataReceived(data) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/internet/tcp.py", line 215, in _dataReceived rval = self.protocol.dataReceived(data) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/protocols/basic.py", line 571, in dataReceived why = self.lineReceived(line) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/mail/imap4.py", line 2356, in lineReceived self._regularDispatch(line) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/mail/imap4.py", line 2383, in _regularDispatch tag, rest = parts exceptions.ValueError: need more than 1 value to unpack My code is as simple as possible and the exception is thrown by the following codes: dlist = [] for msg in messages: # use message number, not UID d = self.fetchMessage(msg, uid=False) d.addCallback(cbGetAttachment) dlist.append(d) dl = defer.DeferredList(dlist) return dl.addCallback(cbLogout) Is there anybody know about this issue?
On Sep 3, 2015, at 7:55 AM, Wang Yan <snailcoder@163.com> wrote:
Hi,
I've installed Twisted 15.3.0 on Ubuntu 14.04LTS. Excellent work but there's one problem bothering me for a long time: twisted.mail.imap4.IMAP4Client.fetchMessage always throws exception and the exception occured at random, e.g. somtimes the exception occured when the program read the 120th mail, sometimes it occured at the 150th or 200th mail. The traceback of the exception is as follows:
Unhandled Error Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/log.py", line 101, in callWithLogger return callWithContext({"system": lp}, func, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/log.py", line 84, in callWithContext return context.call({ILogContext: newCtx}, func, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/context.py", line 118, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/python/context.py", line 81, in callWithContext return func(*args,**kw) --- <exception caught here> --- File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/internet/posixbase.py", line 597, in _doReadOrWrite why = selectable.doRead() File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/internet/tcp.py", line 209, in doRead return self._dataReceived(data) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/internet/tcp.py", line 215, in _dataReceived rval = self.protocol.dataReceived(data) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/protocols/basic.py", line 571, in dataReceived why = self.lineReceived(line) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/mail/imap4.py", line 2356, in lineReceived self._regularDispatch(line) File "/usr/local/lib/python2.7/dist-packages/Twisted-15.3.0-py2.7-linux-i686.egg/twisted/mail/imap4.py", line 2383, in _regularDispatch tag, rest = parts exceptions.ValueError: need more than 1 value to unpack
My code is as simple as possible and the exception is thrown by the following codes:
dlist = [] for msg in messages: # use message number, not UID d = self.fetchMessage(msg, uid=False) d.addCallback(cbGetAttachment) dlist.append(d) dl = defer.DeferredList(dlist) return dl.addCallback(cbLogout)
Is there anybody know about this issue?
Hi Wang, Sorry it took some time to get back to you. What kind of mail server are you talking to? This looks like a protocol error - perhaps a bug in the server you're talking to, perhaps a bug in Twisted's handling of a valid response - but it's hard to say more without looking at the traffic and the intended behavior. (I am no longer well-versed enough in the IMAP protocol to guess what is going on at a glance). Is there any chance you have ever managed to reproduce this on a small set of data? -glyph
participants (2)
-
Glyph Lefkowitz
-
Wang Yan