Discuss / Python / Windows系统下的Anaconda扩展包好像没办法进行多进程

Windows系统下的Anaconda扩展包好像没办法进行多进程

Topic source

天命破凰

#1 Created at ... [Delete] [Delete and Lock User]

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('Child process will start.') p.start() p.join() print('Child process end.')

这里p.start()语句没有任何效果 不知道是不是环境布置错了还是,求指点

zzgaot

#2 Created at ... [Delete] [Delete and Lock User]

用自带的IDE不显示子进程的,只显示 Parent process 7880. Child process will start. Child process end. 换成pycharm后就和廖老师的结果差不多了, Parent process 3072. Child process will start. Run child process test (10056)... Child process end.

第二个例子也是的,得用pycharm才显示,但是不知道为什么,求高手解释吧!

ShiningLoong

#3 Created at ... [Delete] [Delete and Lock User]

参考官方文档的说明: Functionality within moultiprocessing requires that the main module be importable by the children. This is covered in Programming guidelines however it is worth pointing out here. This means that some examples, such as the multiprocessing.pool.Pool examples will not work in the interactive interpreter.

interactive interpreter 指的就是IDLE中带 >>> 这个符号的界面 有兴趣就读一读吧 https://docs.python.org/3.7/library/multiprocessing.html?highlight=multiprocessing#module-multiprocessing


  • 1

Reply