new threadsome msgnums changed def ondeleteprogress(selfinpopup)popup changetext('% of % (in)def getmessages(selfmsgnumsafter)""threadedprefetch all selected messages into cache nowused by saveviewreplyand forward to prefill cachemay overlap with other loadmsgs and sendsdisables delete,loadonly runs "afteraction if the fetch allowed and successful cache getmessages tests if index in synch with serverbut we only test if we have to go to servernot if cached see messagecache notenow avoids potential fetch of mail currently being fetchedif user clicks again while in progressany message being fetched by any other request in progress must disable entire toload batchelseneed to wait for other loadsfetches are still allowed to overlap in timeas long as disjoint""if loadinghdrsbusy or deletingbusyshowerror(appname'cannot fetch message during load or delete'elsetoload [num for num in msgnums if not self cache isloaded(num)if not toloadafter(all already loaded return process nowno wait pop up elseif set(toloadself beingfetched any in progressshowerror(appname'cannot fetch any message being fetched'elseself beingfetched |set(toloadloadingmsgsbusy incr(from popuputil import busyboxnowait popup busyboxnowait(appname'fetching message contents'threadtools startthreadaction self cache getmessagesargs (toload,)context (afterpopuptoload)onexit self onloadmsgsexitonfail self onloadmsgsfailonprogress self onloadmsgsprogressdef onloadmsgsexit(selfafterpopuptoload)self beingfetched -set(toloadpopup quit(after(loadingmsgsbusy decr(allow other actions after onexit done def onloadmsgsfail(selfexc_infoafterpopuptoload)self beingfetched -set(toloadpopup quit(showerror(appname'fetch failed\ % \ %sexc_info[: ]printstack(exc_infoloadingmsgsbusy decr( the pymailgui client