0

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.

  • I don't know what do you mean by 'not working' (you have to be more specific). I suppose that the processes are created but you don't get the results you expect. If it helps, i copied the program and i got the output test: 5000 Finished (1000, 0) – pandy giankoulidis Jun 02 '22 at 10:20
  • Thanks you. On the computer I used, the ipython kernel got stucked. I waited 10 min without any results. I tried it 10 times, same results (huuum same no result in fact). I had to kill the kernel each time. I'm going to try to run this code on a different computer. – Charles Chapus Jun 02 '22 at 12:21
  • The code looks correct to me except `r` will be undefined in function `f` . – Booboo Jun 02 '22 at 16:28
  • Yes my mistake. The code is working in command line. But not on our three spyder installation. I do not really care, but my coworkers need spyder. I need to find a workaround. – Charles Chapus Jun 03 '22 at 09:00

0 Answers0