‘multiprocessing.current_process()’
method is used to the Process object corresponding to the current process.
import multiprocessing def print_process_details(): process=multiprocessing.current_process() print("Process id : ", process.pid) if __name__=="__main__" : process1 = multiprocessing.Process(target=print_process_details) process2 = multiprocessing.Process(target=print_process_details) process1.start() process2.start()
Output
Process id
: 81794
Process id : 81795
Process id : 81795
No comments:
Post a Comment