i wanna use all cpu in a python script i find some code same :
def do_sum():
min = 0
max = 100000000
while min < max:
min += 1
file = open('mytext.txt','a')
file.write(str(min))
def main():
q = Queue()
p1 = Process(target=do_sum)
p2 = Process(target=do_sum)
p1.start()
p2.start()
r1 = q.get()
r2 = q.get()
print r1+r2
if __name__=='__main__':
main()
but it's not match cpu together p1 start write from 1,2,3,4,5 .... and p2 not continue p2 also start from begin 1,2,3,4 so result is : 1122334455
how i can match 2 core of cpu together ? i want write file with fastest my PC can do it , i use i7 cpu ,how can i use all