Hi Exarkun, Ah, that should work correctly and as catered in the framework. Btw, for imap4.py i have a suggestion to improve the performance in fetch : Fetch can be an expensive operation if the number of messages is a lot, this can be more "reactor" friendly if we use "fetch" as a generator. def fetch(self, messages, uid): yield xxxx Then imap4.py needs to update the __cbManualSearch to use this instead of "reactor.callLater( .....result[5:], tag..)" (see attached). Marcus. exar...@twistedmatrix.com wrote: On 16 Oct, 02:02 pm, mar...@internetnowasp.net wrote:Hi,This might seems like a trivial question or at least i would have thought so but it has eluded me for some time on how to do this elegantly. In twisted mail, since the only part where we instantiate an instance of account is under : def requestAvatar(self, avatarId, mind, *interfaces): account = xxinterface() # instantiate our account How do i find out if a particular connection is already dead in the given "account" class? For smtp for example, "mind" is None and avatarId is just the id of the login user. Even if this is pop3 or imap, the same problem arise how do i know if the connection of the particular "Server" instance is dead.Perhaps you want to do something with the logout callback that requestAvatar is also responsible for returning? The SMTP protocol implementation will call it when the connection is lost. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python |
def __cbManualSearch(self, result, tag, mbox, query, uid, searchResults=None): """ Marcus, i modified so this supports a generator instead of a list """ if searchResults is None: searchResults = [] i = 0 ineedbreak = False for (id, msg) in result : # searchFilter and singleSearchStep will mutate the query. Dang. # Copy it here or else things will go poorly for subsequent # messages. if self._searchFilter(copy.deepcopy(query), id, msg, len(mbox.listuids), mbox.listuids[-1]): if uid: searchResults.append(str(msg.getUID())) else: searchResults.append(str(id)) # the break must be here else we will miss the 5th of all mails i += 1 if i % 5 == 0: ineedbreak = True break if ineedbreak : from twisted.internet import reactor # result is now a generator! reactor.callLater(0, self.__cbManualSearch, result, tag, mbox, query, uid, searchResults) else : if searchResults: self.sendUntaggedResponse('SEARCH ' + ' '.join(searchResults)) self.sendPositiveResponse(tag, 'SEARCH completed')
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python