I am trying to process a file using the single core of my CPU. But I guess it is not sufficient to use a single core. Instead, if I had get an access to the multiple cores of my system then I can make the process run better and faster.
But unfortunately, I know to process a file using single core only. Here is what I did:
data = open('datafile','r',encoding='ascii',errors='ignore')
for line in data.readlines():
splitted = line.lower().strip().split()
check = process(splitted[0],splitted[1])
if check == '':
pass
data.close()
I want to know how I can use the complete capacity of the CPU for processing teh process() while taking the line separately and getting the output as desired? Even how I can avoid the deadlock state of the thread while processing as this can be dangerous for the process output.
Please share your view with me.
multiprocesing.Pooland send "chunks" of the file to it from the main process for parallel procesing.