[問題] 關於multiprocess範例
各位大大好:
最近小弟想學習多進程的使用方式,但看了很多網路上的範例
我發現我的電腦總是無法顯示加入多進程的函數本身print的內容
例如:
#-*- coding:utf-8 -*-
from multiprocessing import Process
import os
def run_proc(name):
print 'Run child process %s (%s)...' % (name, os.getpid())
if __name__=='__main__':
print 'Parent process %s.' % os.getpid()
p = Process(target=run_proc, args=('test',))
print 'Process will start.'
p.start()
p.join()
print 'Process end.'
上述的程式碼,教學文章表示執行後應該顯示
Parent process XXX.
Process will start.
Run child process test (929)...
Process end.
但我在執行後,會無法出現函數中的Run child process test 這行
僅會顯示三行,這是為什麼呢?
是否有大大能提點一下...感激!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.160.32.193
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1491408475.A.460.html
→
04/06 00:17, , 1F
04/06 00:17, 1F
→
04/06 09:31, , 2F
04/06 09:31, 2F
推
04/06 09:47, , 3F
04/06 09:47, 3F
→
04/06 10:16, , 4F
04/06 10:16, 4F
→
04/06 10:17, , 5F
04/06 10:17, 5F
→
04/06 12:24, , 6F
04/06 12:24, 6F
→
04/06 14:18, , 7F
04/06 14:18, 7F
推
04/06 19:55, , 8F
04/06 19:55, 8F
→
04/06 19:55, , 9F
04/06 19:55, 9F
推
04/06 20:19, , 10F
04/06 20:19, 10F
→
04/06 20:21, , 11F
04/06 20:21, 11F
Python 近期熱門文章
PTT數位生活區 即時熱門文章