Python enables Parallel Running of multiple sub-processes.
This example describes how to enable Parallel Running of multiple sub-processes in python. Share it with you for your reference. The details are as follows:
This python code creates multiple process Sub-processes. After the sub-processes are created, start () and join are performed in a unified manner. In this way, all sub-processes are executed in parallel.
From multiprocessing import Processimport sys, osimport timedef timetask (times): time. sleep (times) print time. localtime () def works (func, arg, worknum): proc_record = [] for I in range (worknum): p = Process (target = func, args = (arg ,)) p. start () proc_record.append (p) for p in proc_record: p. join () if _ name _ = '_ main _': arg = 5 procs = 4 works (timetask, arg, procs)
I hope this article will help you with Python programming.