Python 进程与多线程

10 进程和多线程

      10.1 多进程

                  

# -*- coding: utf-8 -*-

import os

pid=os.fork()

print ('process (%s)start ...' %os.getpid())

if pid==0:

         print('I am child process (%s) and my parent is %s.' % (os.getpid(), os.getppid()))

else:

        print('I (%s) just created a child process (%s).' % (os.getpid(), pid))

posted @ 2017-11-28 18:09  smartwen  阅读(138)  评论(0编辑  收藏  举报