加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

在Windows上新的Python期货模块只是我或者是严重错误的

发布时间:2020-12-14 04:02:27 所属栏目:Windows 来源:网络整理
导读:我在 Windows XP上,我遇到了新的 Python 3.2期货模块的问题. 好像我无法让ProcessPoolExecutor工作. 会话示例: Python 3.2 (r32:88445,Feb 20 2011,21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help","copyright","credits" or "license" for mo
我在 Windows XP上,我遇到了新的 Python 3.2期货模块的问题.
好像我无法让ProcessPoolExecutor工作.
会话示例:

Python 3.2 (r32:88445,Feb 20 2011,21:29:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help","copyright","credits" or "license" for more information.  

>>> from concurrent import futures  
>>> executor = futures.ProcessPoolExecutor()  
>>> def pio(x):  
...     print("I AM HERE")  
...     return True  
...  
>>> fut = executor.submit(pio,5)  
>>> Process Process-1:  
Traceback (most recent call last):  
File "C:Python32libmultiprocessingprocess.py",line 259,in _bootstrap  
  self.run()  
File "C:Python32libmultiprocessingprocess.py",line 114,in run  
  self._target(*self._args,**self._kwargs)  
File "C:Python32libconcurrentfuturesprocess.py",line 133,in _process_worker  
  call_item = call_queue.get(block=True,timeout=0.1)
File "C:Python32libmultiprocessingqueues.py",line 131,in get
res = self._recv()
AttributeError: 'module' object has no attribute 'pio'

>>> fut.running()
True

这对我来说看起来有些不对劲.救命 !

解决方法

您必须知道 concurrent.future模块使用 multiprocessing模块(特别是当您使用ProcessPoolExecutor时),因此某些功能在交互式解释器中不起作用,请参阅Note here.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读