Skip to content Skip to sidebar Skip to footer

Multiprocessing With Python Process

I'm trying to modify a Python script to multiprocess with 'Process'. The problem is it's not working. In a first step, the content is retrieved sequentially (test1, test2). In a se

Solution 1:

Your code is executing sequentially because instead of passing test1 to the Process's target argument you are passing test1's result to it!

You want to do this:

worker_1 = multiprocessing.Process(target=test1, args=(100,))

As you do in the other call not this:

worker_1 = multiprocessing.Process(target=test1(100))

This code is first executing test1(100), then returns None and assigns that to target spawning an "empty process". After that you spawn a second process that executes test2(100). So you execute the code sequentially plus you add the overhead of spawning two processes.


Post a Comment for "Multiprocessing With Python Process"