#!/usr/bin/env python
# encoding: utf-8
# Date: 2018/6/16
from multiprocessing import Process
import time, os
# 定义task,开启进程就是执行任务
def task():
# print('%s is running' % os.getpid()) # 33808 is running
print('%s is running, parent id is <%s>' % (os.getpid(), os.getppid()))
# parent id is <5384>,与进程print('主', os.getpid()) 相同
time.sleep(3)
print('%s is done' % os.getpid()) # 33808 is done
if __name__ == '__main__':
p = Process(target=task,)
p.start()
# 主进程开始(下面print)
print('主', os.getpid()) # 主 20096 (就是pycharm的id)