python37-32_讨论 - 廖雪峰的官方网站

在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:\tool\Python37-32\lib\multiprocessing\spawn.py", line 105, in spawn_main

exitcode = _main(fd)

File "G:\tool\Python37-32\lib\multiprocessing\spawn.py", line 114, in _main

prepare(preparation_data)

File "G:\tool\Python37-32\lib\multiprocessing\spawn.py", line 225, in prepare

_fixup_main_from_path(data['init_main_from_path'])

File "G:\tool\Python37-32\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path

run_name="__mp_main__")

File "G:\tool\Python37-32\lib\runpy.py", line 263, in run_path

pkg_name=pkg_name, script_name=fname)

File "G:\tool\Python37-32\lib\runpy.py", line 96, in _run_module_code

mod_name, mod_spec, pkg_name, script_name)

File "G:\tool\Python37-32\lib\runpy.py", line 85, in _run_code

exec(code, run_globals)

File "G:\workspace\PycharmProjects\02\task_master.py", line 44, in

manager.start()

File "G:\tool\Python37-32\lib\multiprocessing\managers.py", line 543, in start

self._process.start()

File "G:\tool\Python37-32\lib\multiprocessing\process.py", line 112, in start

self._popen = self._Popen(self)

File "G:\tool\Python37-32\lib\multiprocessing\context.py", line 322, in _Popen

return Popen(process_obj)

File "G:\tool\Python37-32\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__

prep_data = spawn.get_preparation_data(process_obj._name)

File "G:\tool\Python37-32\lib\multiprocessing\spawn.py", line 143, in get_preparation_data

_check_not_importing_main()

File "G:\tool\Python37-32\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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值