Do something simlar by forking process instead of threads : System fork : System PYTHON examples


PYTHON examples » System » System fork »

 

Do something simlar by forking process instead of threads



import os, sys

def counter(count):
    for i in range(count): print '[%s=> %s' % (os.getpid(), i)

for i in range(10):
    pid = os.fork()
    if pid != 0:
        print 'Process %d spawned' % pid
    else:
        counter(100)
        sys.exit()

print 'Main process exiting.'

           
       



    Related Scripts with Example Source Code in same category :

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo System
» System fork