When I am running my python code that uses multiprocessing
, it is using all 8 cores and my system is hanging. I added the following line, but it didn't help.
po = multiprocessing.Pool(processes=4)
recursive code is as follows:
def func(a,i):
if (a>i):
func(a-1,i)
func(a-5,i)
else print a
Now above 2 recursive calls can be put into threads as they are independent of each other.
Below is the code.
import multiprocessing
po = multiprocessing.Pool(processes=2)
p=bin(47)
q=bin(59)
def func(r,i):
if( p[i]==r[i])
po = multiprocessing.Process(target=func, args=(2*r, i+1))
po.start()
po = multiprocessing.Process(target=func, args=((2*r)+1, i+1))
po.start()
func(1,1)