def precompute_cache_for_person(person_ids=None, all_persons=False, only_expired=False): pids = set() if all_persons: pids = get_existing_authors(with_papers_only=True) elif only_expired: pids = set(get_expired_person_ids()) if person_ids: pids |= set(person_ids) empty_pids = remove_empty_authors(remove=False) pids = pids - empty_pids last = len(pids) global IS_BATCH_PROCESS IS_BATCH_PROCESS = True for i, p in enumerate(pids): # start = time() print 'Doing ', i, ' of ', last #print 'STARTED: ', p, ' ', i _compute_cache_for_person(p) #print 'DONE: ', p , ',' , str(time() - start) IS_BATCH_PROCESS = False
def multiprocessing_precompute_cache_for_person(person_ids=None, all_persons=False, only_expired=False): pids = set() if all_persons: pids = get_existing_authors(with_papers_only=True) elif only_expired: pids = set(get_expired_person_ids()) if person_ids: pids |= person_ids from multiprocessing import Pool p = Pool() p.map(_compute_cache_for_person, pids)
def precompute_cache_for_person(person_ids=None, all_persons=False, only_expired=False): pids = set() if all_persons: pids = get_existing_authors(with_papers_only=True) elif only_expired: pids = set(get_expired_person_ids()) if person_ids: pids |= person_ids empty_pids = remove_empty_authors(remove=False) pids = pids - empty_pids last = len(pids) global IS_BATCH_PROCESS IS_BATCH_PROCESS = True for i, p in enumerate(pids): # start = time() print 'Doing ', i,' of ', last #print 'STARTED: ', p, ' ', i _compute_cache_for_person(p) #print 'DONE: ', p , ',' , str(time() - start) IS_BATCH_PROCESS = False