this may change in future python/emailsee for details changeinherits the new mailconfig fetchlimit feature of mailtoolswhich can be used to limit the maximum number of most recent headers or full mails (if no topfetched on each load requestnote that this feature is independent of the loadfrom used here to limit loads to newly-arrived mails onlythough it is applied at the same timeat most fetchlimit newly-arrived mails are loaded changethough unlikelyit' not impossible that user may trigger new fetch of message that is currently being fetched in threadsimply by clicking the same message again (msg fetchesbut not full index loadsmay overlap with other fetches and sends)this seems to be thread safe herebut can lead to redundant and possibly parallel downloads of the same mail which are pointless and seem odd (selecting all mails and pressing view twice downloads most messages twice!)fixed by keeping track of fetches in progress in the main gui thread so that this overlap is no longer possiblea message being fetched disables any fetch request which it is part ofand parallel fetches are still allowed as long as their targets do not intersect#############################################################################""from pp internet email import mailtools from popuputil import askpasswordwindow class messageinfo""an item in the mail cache list ""def __init__(selfhdrtextsize)self hdrtext hdrtext self fullsize size self fulltext none fulltext is cached msg hdrtext is just the hdrs fulltext=hdrtext if no top class messagecache(mailtools mailfetcher)""keep track of already loaded headers and messagesinherits server transfer methods from mailfetcheruseful in other appsno gui or thread assumptions raw mail text bytes are decoded to str to be parsed with py ' email pkg and saved to filesuses the local mailconfig module' encoding settingdecoding happens automatically in mailtools on fetch""def __init__(self)mailtools mailfetcher __init__(self inherits fetchencoding self msglist [ inherits fetchlimit def loadheaders(selfforcereloadsprogress=none)""three cases to handle herethe initial full load the pymailgui client