how to get the process id from python multiprocess

Solutions on MaxInterview for how to get the process id from python multiprocess by the best coders in the world

showing results for - "how to get the process id from python multiprocess"
Yannic
13 Aug 2017
1from multiprocessing import Process
2import sys
3import time
4
5def say_hello(name='world'):
6    print "Hello, %s" % name
7    print 'Starting:', p.name, p.pid
8    sys.stdout.flush()
9    print 'Exiting :', p.name, p.pid
10    sys.stdout.flush()
11    time.sleep(20)
12
13p = Process(target=say_hello)
14p.start()