[Python-checkins] cpython (3.3): #16307: Fix multiprocessing.Pool.map_async not calling its callbacks
hynek.schlawack
python-checkins at python.org
Sat Oct 27 12:58:13 CEST 2012
http://hg.python.org/cpython/rev/1bccec4ff980
changeset: 79961:1bccec4ff980
branch: 3.3
parent: 79958:30547e2cd04d
user: Hynek Schlawack <hs at ox.cx>
date: Sat Oct 27 12:53:02 2012 +0200
summary:
#16307: Fix multiprocessing.Pool.map_async not calling its callbacks
Patch by Janne Karila.
files:
Lib/multiprocessing/pool.py | 3 ++-
Lib/test/test_multiprocessing.py | 17 +++++++++++++++++
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
4 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -297,7 +297,8 @@
'''
Asynchronous version of `map()` method.
'''
- return self._map_async(func, iterable, mapstar, chunksize)
+ return self._map_async(func, iterable, mapstar, chunksize, callback,
+ error_callback)
def _map_async(self, func, iterable, mapper, chunksize=None, callback=None,
error_callback=None):
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1642,6 +1642,23 @@
self.assertEqual(self.pool.starmap_async(mul, tuples).get(),
list(itertools.starmap(mul, tuples)))
+ def test_map_async(self):
+ self.assertEqual(self.pool.map_async(sqr, list(range(10))).get(),
+ list(map(sqr, list(range(10)))))
+
+ def test_map_async_callbacks(self):
+ call_args = self.manager.list() if self.TYPE == 'manager' else []
+ self.pool.map_async(int, ['1'],
+ callback=call_args.append,
+ error_callback=call_args.append).wait()
+ self.assertEqual(1, len(call_args))
+ self.assertEqual([1], call_args[0])
+ self.pool.map_async(int, ['a'],
+ callback=call_args.append,
+ error_callback=call_args.append).wait()
+ self.assertEqual(2, len(call_args))
+ self.assertIsInstance(call_args[1], ValueError)
+
def test_map_chunksize(self):
try:
self.pool.map_async(sqr, [], chunksize=1).get(timeout=TIMEOUT1)
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -594,6 +594,7 @@
Peter van Kampen
Rafe Kaplan
Jacob Kaplan-Moss
+Janne Karila
Per Øyvind Karlsen
Lou Kates
Hiroaki Kawai
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,9 @@
Library
-------
+- Issue #16307: Fix multiprocessing.Pool.map_async not calling its callbacks.
+ Patch by Janne Karila.
+
- Issue #16250: Fix URLError invocation with proper args.
- Issue #16116: Fix include and library paths to be correct when building C
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list