startover / pythonfutures

Automatically exported from code.google.com/p/pythonfutures
Other
0 stars 0 forks source link

ProcessPoolExecutor is broken #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Plus, the Python process gets stuck in a state where KeyboardInterrupt doesn't 
work.

As of latest release (2.1.2):

$ ipython
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import futures
/home/yang/env/lib/python2.6/site-packages/futures/__init__.py:24: 
DeprecationWarning: The futures package has been deprecated. Use the 
concurrent.futures package instead.
  DeprecationWarning)

In [2]: from concurrent.futures import *

In [3]: def go(x): print x
   ...: 

In [4]: with ProcessPoolExecutor(1) as p: list(p.map(go, range(3)))
   ...: 
Traceback (most recent call last):
  File "/home/yang/env/lib/python2.6/multiprocessing/queues.py", line 242, in _feed
    send(obj)
PicklingError: Can't pickle <type 'function'>: attribute lookup 
__builtin__.function failed

^CProcess Process-1:
Traceback (most recent call last):
  File "/home/yang/env/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
  File "/home/yang/env/lib/python2.6/multiprocessing/process.py", line 88, in run 
    self._target(*self._args, **self._kwargs)
  File "/home/yang/env/lib/python2.6/site-packages/concurrent/futures/process.py", line 140, in _process_worker
    call_item = call_queue.get(block=True, timeout=0.1)
  File "/home/yang/env/lib/python2.6/multiprocessing/queues.py", line 103, in get 
    if not self._poll(block and (deadline-time.time()) or 0.0):
KeyboardInterrupt

Original issue reported on code.google.com by yaa...@gmail.com on 19 Apr 2011 at 9:28

GoogleCodeExporter commented 9 years ago
Works for me:

Python 2.6.8 (default, May 12 2012, 12:41:44) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from concurrent.futures import ProcessPoolExecutor
>>> def go(x): print x
... 
>>> with ProcessPoolExecutor(1) as p: list(p.map(go, range(3)))
... 
0
1
2
[None, None, None]

Original comment by Dema...@gmail.com on 25 Aug 2012 at 1:54

GoogleCodeExporter commented 9 years ago
Bizarre. Works for me now too.

Original comment by yaa...@gmail.com on 25 Aug 2012 at 5:14

GoogleCodeExporter commented 9 years ago
(I'm also using a newer Python - not sure if that makes a difference)

Original comment by yaa...@gmail.com on 25 Aug 2012 at 5:14

GoogleCodeExporter commented 9 years ago
i'm having the same problem with python 2.6.8, what version of python are u 
using when it works finally

Original comment by xiaotian...@gmail.com on 20 Jun 2013 at 9:14

GoogleCodeExporter commented 9 years ago
I was using Python 2.7.  Not sure if this was the exact version I was using at 
the time but I'm currently on 2.7.3.

Original comment by yaa...@gmail.com on 20 Jun 2013 at 7:19