How can i create a process execution in serial fashion vs parallel fashion?
For example i want each process to execute the following python function:
def execute():
time.sleep(random.randint(0,9))
If i run the processes like:
for process in process_list:
process.run()
Given a scenario of only 2 processes in a serial fahsion i would expect the output of the program to be exatcly:
process 1 - start
process 1 - end
process 2 - start
process 2 - end
In a parallel scenario i would expect a possible output such as:
process 1 - start
process 2 - start
process 2 - end
process 1 - end
How can i replicate these two scenarios in python with a processing module?
By using multiprocessing
or subprocess
modules?