-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiprocessing not compatible with functools.partial #49478
Comments
from multiprocessing import Pool
def power (x, pwr=2):
return x**pwr
import functools
run_test = functools.partial (power, pwr=3)
if __name__ == "__main__":
pool = Pool()
cases = [3,4,5]
results = pool.map (run_test, cases) TypeError: type 'partial' takes at least one argument
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-
self.run()
File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-
self._target(*self._args, **self._kwargs)
File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-
task = get()
File "/usr/lib/python2.5/site-packages/multiprocessing-2.6.1.1-py2.5-
return recv()
TypeError: type 'partial' takes at least one argument |
See this mail thread: |
Rather than implement a multiprocessing-specific fix, it would certainly |
I would tend to agree |
I agree that this is a nice feature, however it requires adding a I would need a patch which does this, and adds tests to the |
Jack offered to take a peek |
Fixed rev 70931. Happy pickling! |
I think this bug still exists in Python 2.6.4, and I haven't tested 2.6.5, but since 2.6.4 was released 6 months after this bug was closed I assume it's still an issue. Running ndbecker's test program as is produces the following output on Solaris 10: Process PoolWorker-1:
Process PoolWorker-2:
Traceback (most recent call last):
Traceback (most recent call last):
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
Process PoolWorker-3:
Traceback (most recent call last):
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
self.run()
self.run()
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/process.py", line 88, in run
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/process.py", line 88, in run
self._target(*self._args, **self._kwargs)
self._target(*self._args, **self._kwargs)
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/pool.py", line 57, in worker
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/pool.py", line 57, in worker
self.run()
task = get()
task = get()
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/queues.py", line 352, in get
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/process.py", line 88, in run
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/queues.py", line 352, in get
self._target(*self._args, **self._kwargs)
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/pool.py", line 57, in worker
return recv()
return recv()
TypeError: type 'partial' takes at least one argument
TypeError: type 'partial' takes at least one argument
task = get()
File "/opt/app/g++lib6/python-2.6/lib/python2.6/multiprocessing/queues.py", line 352, in get
return recv()
TypeError: type 'partial' takes at least one argument |
The bug still exists in 2.6.6 Process PoolWorker-2:
Traceback (most recent call last):
Process PoolWorker-1:
Traceback (most recent call last):
File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
self.run()
self.run()
File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run
File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run
self._target(*self._args, **self._kwargs)
self._target(*self._args, **self._kwargs)
File "/usr/lib/python2.6/multiprocessing/pool.py", line 57, in worker
File "/usr/lib/python2.6/multiprocessing/pool.py", line 57, in worker
task = get()
task = get()
File "/usr/lib/python2.6/multiprocessing/queues.py", line 352, in get
File "/usr/lib/python2.6/multiprocessing/queues.py", line 352, in get
return recv()
return recv()
TypeError: type 'partial' takes at least one argument
TypeError: type 'partial' takes at least one argument |
The bug was fixed in 2.7, and not backported to 2.6. |
Unfortunately, upgrading to 2.7 is not an option for me, since my application works on Debian stable which only includes 2.6. For now I'm settled with the following workaround: http://paste.pocoo.org/show/351774/ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: