Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from multiprocessing import Process,Queue,current_process
- import _pickle as pickle
- def dataRead(queue,fileName):
- proc_name = current_process().name
- print('{}.pkl'.format(fileName),proc_name,time.time(),'...Start')
- with open('{}.pkl'.format(fileName), 'rb') as file:
- data = pickle.load(file )
- file.close()
- print('{}.pkl'.format(fileName),proc_name,time.time(),'...finish')
- queue.put((fileName,data))
- print('puts : ',fileName)
- if __name__ == '__main__':
- fileNameList = ['userUserSimilarity','topNeighborsIndexNumber','ratings_diff','mean_user_item','indexToFeature']
- queue = Queue()
- processes = []
- for filename in fileNameList:
- p = Process(target=dataRead,args=(queue,filename))
- processes.append(p)
- p.start()
- for p in processes:
- listName,listValue = queue.get()
- globals()[listName] = listValue
- print('*'*10,p,listName)
- for p in processes:
- p.join()
- print('*'*7,p)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement