Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it just me or something is seriously wrong with new Python futures module on windows

I am on windows XP and I have problems with new Python 3.2 futures module. It seems I am unable to get ProcessPoolExecutor to work. Session example:

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:\Python32\lib\multiprocessing\process.py", line 259, in _bootstrap  
  self.run()  
File "C:\Python32\lib\multiprocessing\process.py", line 114, in run  
  self._target(*self._args, **self._kwargs)  
File "C:\Python32\lib\concurrent\futures\process.py", line 133, in _process_worker  
  call_item = call_queue.get(block=True, timeout=0.1)
File "C:\Python32\lib\multiprocessing\queues.py", line 131, in get
res = self._recv()
AttributeError: 'module' object has no attribute 'pio'

>>> fut.running()
True

It looks like something is wrong here to me.

like image 651
Piotr Lopusiewicz Avatar asked Jan 21 '23 09:01

Piotr Lopusiewicz


1 Answers

You have to be aware that the concurrent.future module uses the multiprocessing module (especially when you used the ProcessPoolExecutor), so some functionality will not work in the interactive interpreter, read more about this here.

like image 193
mouad Avatar answered Apr 28 '23 04:04

mouad