New submission from Chris Curvey:

on http://docs.python.org/2/library/multiprocessing.html, there is a bit about 
how to use a Pool properly, which looks like this

pool = Pool(processes=4)              # start 4 worker processes
result = pool.apply_async(f, [10])

What this neglects to mention is that only one process will get any of the 
work.  If you really want four processes in the pool to work, you have to call 
apply_async four times.  For example:

results = []
pool = Pool(processes=4)
for i in xrange(4):
    results.append(pool.apply_async(f, [10]))

hat tip to 
http://stackoverflow.com/questions/12483512/python-multiprocessing-apply-async-only-uses-one-process

----------
assignee: docs@python
components: Documentation
messages: 194115
nosy: Chris.Curvey, docs@python
priority: normal
severity: normal
status: open
title: multiprocessing page leaves out important part of Pool example
type: enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18620>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to