0
How to run two python functions in parallel?
I am trying to run two python functions in parallel in python 3.7. Here is my code: from multiprocessing import Process import sys def funn1(): for i in range(10): print('a', i) def funn2(): for b in range(20): print('b', b) if __name__=='__main__': p1 = Process(target = funn1) p1.start() p2 = Process(target = funn2) p2.start() p1.join() p2.join() I am expecting to see a1 getting printed first and the second line needs to be b1. Instead, I am getting funn1 runs completely than funn2 starts which is not what I want.
1 Resposta
+ 1
I am not good so much at python
But i found this link helpful..
Try it
https://stackabuse.com/parallel-processing-in-python/