(account_key, folder_name, uid_parts)
return emails
Get email parts (body parts) for a given folder and a given map of
    UID -> part ID. This happens in parallel for different part ID given, as
    IMAP cannot return different parts of different messages in each request.
Get email parts (body parts) for a given folder and a given map of
    UID -> part ID. This happens in parallel for different part ID given, as
    IMAP cannot return different parts of different messages in each request.
Get email parts ( body parts ) for a given folder and a given map of UID - > part ID . This happens in parallel for different part ID given as IMAP cannot return different parts of different messages in each request .
def _get_folder_email_parts(account_key, folder_name, uid_parts):
    '''
    Get email parts (body parts) for a given folder and a given map of
    UID -> part ID. This happens in parallel for different part ID given, as
    IMAP cannot return different parts of different messages in each request.
    '''

    # Make map of part ID -> UIDs
    part_to_uid = defaultdict(list)

    for uid, part in uid_parts:
        part_to_uid[part].append(uid)

    account = get_account(account_key)
    folder = account.get_folder(folder_name)

    def get_email_parts(uids, part):
        email_parts = folder.get_email_parts(uids, part)
        return (part, email_parts)

    items = execute_threaded(get_email_parts, [
        (uids, part)
        for part, uids in part_to_uid.items()
    ])

    emails = defaultdict(dict)

    for part, email_parts in items:
        for uid, data in email_parts.items():
            emails[uid][part] = data

    return emails
def _get_folder_email_parts ( account_key , folder_name , uid_parts ) : # Make map of part ID -> UIDs part_to_uid = defaultdict ( list ) for uid , part in uid_parts : part_to_uid [ part ] . append ( uid ) account = get_account ( account_key ) folder = account . get_folder ( folder_name ) def get_email_parts ( uids , part ) : email_parts = folder . get_email_parts ( uids , part ) return ( part , email_parts ) items = execute_threaded ( get_email_parts , [ ( uids , part ) for part , uids in part_to_uid . items ( ) ] ) emails = defaultdict ( dict ) for part , email_parts in items : for uid , data in email_parts . items ( ) : emails [ uid ] [ part ] = data return emails