概述
在windows下运行出现RuntimeError错误,有谁知道吗?
部分代码如下:
def return_task_queue():
global task_queue
return task_queue
def return_result_queue():
global result_queue
return result_queue
class QueueManager(BaseManager):
pass
# windows
QueueManager.register('get_task_queue', callable=return_task_queue)
QueueManager.register('get_result_queue', callable=return_result_queue)Traceback (most recent call last):
File "", line 1, in
File "G:toolPython37-32libmultiprocessingspawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "G:toolPython37-32libmultiprocessingspawn.py", line 114, in _main
prepare(preparation_data)
File "G:toolPython37-32libmultiprocessingspawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "G:toolPython37-32libmultiprocessingspawn.py", line 277, in _fixup_main_from_path
run_name="__mp_main__")
File "G:toolPython37-32librunpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "G:toolPython37-32librunpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "G:toolPython37-32librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "G:workspacePycharmProjects 2task_master.py", line 44, in
manager.start()
File "G:toolPython37-32libmultiprocessingmanagers.py", line 543, in start
self._process.start()
File "G:toolPython37-32libmultiprocessingprocess.py", line 112, in start
self._popen = self._Popen(self)
File "G:toolPython37-32libmultiprocessingcontext.py", line 322, in _Popen
return Popen(process_obj)
File "G:toolPython37-32libmultiprocessingpopen_spawn_win32.py", line 33, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "G:toolPython37-32libmultiprocessingspawn.py", line 143, in get_preparation_data
_check_not_importing_main()
File "G:toolPython37-32libmultiprocessingspawn.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.
最后
以上就是老实皮皮虾为你收集整理的python37-32_讨论 - 廖雪峰的官方网站的全部内容,希望文章能够帮你解决python37-32_讨论 - 廖雪峰的官方网站所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复