[Twisted-Python] IMAP fetchUID speed?

Nick Arnett narnett at liveworld.com
Tue Oct 26 12:27:14 MDT 2004


I'm trying to figure out what's happening in an IMAP implementation. 
The server at the moment has a very big backlog -- perhaps 80K messages. 
   I was expecting that if I did this:

d.addCallback(lambda x: self.proto.fetchUID('1:10'))

things would move along quickly... but there's a huge delay somewhere. 
I think it's in that callback, since I've added breakpoints in 
handleuids() and they're not being reached (as they are when I hit a 
smaller mailbox on a different server).

Thanks for any pointers...  I'm brand-new to Twisted, but sure like what 
I'm seeing in it.

Nick

P.S.

I'm using the same sort of approach that John Goerzen's "Python Network 
Programming" book shows:

> class IMAPClient(IMAP4Client):
>     def connectionMade(self):
>         IMAPLogic(self)
>         
> class IMAPFactory(protocol.ClientFactory):
>     protocol = IMAPClient
>     def __init__(self, username, password):
>         self.username = username
>         self.password = password
>         
>     def clientConnectionFailed(self, connector, reason):
>         LOGGER.error("Client connection failed:", reason)
>         reactor.stop()
>         
> class IMAPLogic(mail_archive_retriever):
>     def __init__(self, proto, getting_archives = 0):
>         self.parser = email.Parser.Parser()
>         self.request_topic_id = None
>         self.message_bucket = messagedb.message_inserter()
>         self.getting_archives = getting_archives
>         
>         # Twisted stuff
>         self.proto = proto
>         self.factory = proto.factory
>         d = self.proto.login(self.factory.username, self.factory.password) # d is a Deferred
>         d.addCallback(lambda x: self.proto.select('INBOX'))  # lambda here keeps the output of the previous callback from going into this call
>         d.addCallback(lambda x: self.proto.fetchUID('1:*'))
>         d.addCallback(self.handleuids)
>         d.addCallback(self.deletemessages)
>         d.addCallback(self.logout)
>         d.addCallback(self.stopreactor)
>         d.addErrback(self.errorhappened)






More information about the Twisted-Python mailing list