问题:python多进程,子函数内容没有打印出来。
Simple Python Multiprocessing function doesn't output results
I have this very simple function right here in which I'm trying to run and test on, however, it doesn't output anything and it doesn't have any errors either. I've checked the code multiple times but it doesn't have any errors.
I printed jobs and here's what I got:
[,,,,]
Here's the code:
importmultiprocessingdefworker(num):print"worker ",numreturnjobs=[]foriinrange(5):p=multiprocessing.Process(target=worker,args=(i,))jobs.append(p)p.start()
Here's the result I'm expecting but it's not outputting anything:
Worker:0Worker:1Worker:2Worker:3Worker:4
原因:spyder使用的stdout和windows不支持forking,所以无法打印子进程内容。
The comments revealed that OP uses Windows as well as Spyder. Since Spyder redirectsstdo