RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your c
Error Msg:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python36\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python36\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python36\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Python36\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
Traceback (most recent call last): File "<string>", line 1, in <module>
File "C:\Python36\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Python36\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "C:\Python36\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
run_name="__mp_main__")
File "C:\Python36\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Python36\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\w5659\Desktop\进程池遗留\test2.py", line 6, in <module>
pool = multiprocessing.Pool(5)
File "C:\Python36\lib\multiprocessing\context.py", line 119, in Pool
context=self.get_context())
File "C:\Python36\lib\multiprocessing\pool.py", line 174, in __init__
self._repopulate_pool()
File "C:\Python36\lib\multiprocessing\pool.py", line 239, in _repopulate_pool
w.start()
File "C:\Python36\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "C:\Python36\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "C:\Python36\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Python36\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
_check_not_importing_main()
File "C:\Python36\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
is not going to be frozen to produce an executable.''')
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase. This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module: if __name__ == '__main__':
freeze_support()
... The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
问题:
在windows中, 创建进程由于没有folk创建进程, 所以是通过重载自身模块来创建的, 如果Pool放在if __name__ == "__main__"外部, 就会进行无线递归模块
解决:
from multiprocessing imoprt Pool
if __name__ == "__main__":
p = Pool(10)
RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your c的更多相关文章
- {RuntimeError} An attempt has been made to start a new process before the current process has finished its bootstrapping phase.This probably means that you are not using fork to start your child...
加载数据时出现报错: RuntimeError: An attempt has been made to start a new process before the c ...
- multiprocessing进程开发RuntimeError
windows环境下multiprocessing报如下异常信息: RuntimeError: An attempt has been made to start a new process befo ...
- Python中if __name__=="__main__" 语句在调用多进程Process过程中的作用分析
2018年2月27日 于创B515 引言 最近准备学习一下如何使用Python中的多进程.在翻看相关书籍.网上资料时发现所有代码都含有if __name__=="__main__" ...
- python编程中的if __name__ == 'main与windows中使用多进程
if __name__ == 'main 一个python的文件有两种使用的方法,第一是直接作为程序执行,第二是import到其他的python程序中被调用(模块重用)执行. 因此if __name_ ...
- AssertionError
(1)p1 = multiprocessing.Process(test1)p2 = multiprocessing.Process(target=test2) 错误: p1缺少target,应为(t ...
- python---基础知识回顾(十)进程和线程(py2中自定义线程池和py3中的线程池使用)
一:自定义线程池的实现 前戏: 在进行自定义线程池前,先了解下Queue队列 队列中可以存放基础数据类型,也可以存放类,对象等特殊数据类型 from queue import Queue class ...
- Python(十) —— 多进程多线程
进程线程概念 进程理解为一个程序,具体完成工作的是线程.比如说启动一个 QQ ,QQ 程序里面可以聊天,设置,查找好友等,那么这些功能就理解成各个线程,也就是单进程多线程的一个模式.进程理解成人脑子, ...
- python并发编程-进程理论-进程方法-守护进程-互斥锁-01
操作系统发展史(主要的几个阶段) 初始系统 1946年第一台计算机诞生,采用手工操作的方式(用穿孔卡片操作) 同一个房间同一时刻只能运行一个程序,效率极低(操作一两个小时,CPU一两秒可能就运算完了) ...
- Day033--Python--进程
什么是进程? 进程(Process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位,是操作系统结构的基础.在早期面向进程设计的计算机结构中,进程是程序的基本执行实体 ...
随机推荐
- 一文读懂Https的安全性原理、数字证书、单项认证、双项认证等
本文引用了作者Smily(博客:blog.csdn.net/qq_20521573)的文章内容,感谢无私分享. 1.前言 目前苹果公司已经强制iOS应用必须使用HTTPS协议开发(详见<苹果即将 ...
- webpack4.0各个击破(6)—— Loader篇
webpack作为前端最火的构建工具,是前端自动化工具链最重要的部分,使用门槛较高.本系列是笔者自己的学习记录,比较基础,希望通过问题 + 解决方式的模式,以前端构建中遇到的具体需求为出发点,学习we ...
- linux查看和修改PATH环境变量的方法
查看PATH:echo $PATH以添加mongodb server为列修改方法一:export PATH=/usr/local/mongodb/bin:$PATH//配置完后可以通过echo $PA ...
- [日常] nginx记录post数据
1.使用log_format指令来更改日志格式,该指令只能放在http{}段 log_format 日志名 '日志内容'; server { access_log /var/log/nginx/d ...
- 驰骋工作流引擎JFlow与activiti的对比之4种包含多实例的模式
1. 无同步的多实例(MIwithout) 在流程中,一个活动可以激活多个实例,每个实例相互独立,并不需要在后面进行同步. 例子:比如用户购买了N本书,于是后续的支付账单.更新客户可以以本书为单位各自 ...
- 解决一个Ubuntu中编译NEON优化的OpenCV的错误
在Ubuntu 16中编译开启NEON优化的Opencv时,遇到libpng编译是使用汇编代码的错误,完整错误见文章末尾.通过查询发现解决方案是安装跨平台编译器,安装代码如下: sudo apt-ge ...
- Tips on GORM, Avoid Error about "duplicate column name: id"
The GORM is an super easy ORM solution for Go language. But many people would get the error about du ...
- Ubuntu系统分配存储空间的建议以及给Ubuntu系统根目录扩容方法(从20GB追加100GB)
当初准备装双系统时,也思考了很久分配多少空间给Ubuntu16.04系统,查了许多资料,大多意思是‘/’目录总共给20GB,其他的给/home.网上资料推荐的大多跟这篇文章一样:https://blo ...
- Java 集合系列(一)
Java集合系列文章将以思维导图为主要形式来展示知识点,让零碎的知识形成体系. 这篇文章主要介绍的是[Java 集合的基本知识],即Java 集合简介. 毕业出来一直使用 PHP 进行开发,对于大学所 ...
- git、github、gitlab之间的关系
GIt-版本控制工具:GitHub-一个网站平台,提供给用户空间存储git仓储,保存用户的一些数据文档或者代码等:GitLab - 基于Git的项目管理软件. Git分布式版本控制系统 Git是一款自 ...