Python: Can not get results from simple apply_sync call

33 Views Asked by At

I'm trying to use apply_sync() inside a class object in order to process live signal from external sensors. The processes are created but I'm stuck as soon as I'm trying to get() the results.

I've tried to use a function inside the class or "outside". No luck. So I've minimized the code in order to resolve the issue.

The following code is not working for me and I do not know why. Any help will be appreciated.

from multiprocessing import Pool

def calrr(Data, numID):
   fe = 1000
   fen = 5
   print(f"test: {fe * fen}")
   return fe, numID

def f(res):
   print("Finished", r)

p = Pool(2)
toto = p.apply_async(calrr, args = ([1], 0), callback = f)

p.close()
toto.get()

Edit: to be clearer, the ipython kernel is stuck after I run the last line. Each time, I had to kill the kernel.

0

There are 0 best solutions below