def _preindex_thread(msgs): tracker = {} for msg in msgs: if msg.thread: raise ValueError('This is weird. why am i trying to thread something that already has a thread id?') tracker[msg.msgid[0]] = msg threader = lazythread_container() all_msgs = iterdocs() if all_msgs: print 'yes to all_msgs' all_msgs = map(msg_factory, all_msgs) all_msgs = threadmap.map(conv_factory, all_msgs) threader.thread(all_msgs) print 'threader b4 convs %s' % len(threader) threader.thread( threadmap.map(conv_factory, msgs) ) print 'threader after convs %s' % len(threader) c = 0 ct = 0 for conv in threader: ct+= len(conv.messages) if len(conv.messages) == 1: c+=1 print "found %s threads with one msg" % c print "threader contains %s messages out of a total %s" % (ct, len(msgs)) c = 0 if all_msgs: for key in tracker: msg = tracker[key] try: try: conv = threader[key] except: conv = threader[msg.subject[0]] except: c+=1 ''' print "unable to find msg in thread" print key print msg.subject[0] ''' continue threadid = conv.thread msg.thread.extend(threadid) print "%s messages didn't find a thread" % c return msgs, threader
def refresh(self): ''' refresh all sources to look for new emails. And do every source in a separate thread so we aren't kept waiting. ''' threadmap.map(lambda x: x._refresh(), self)