From 4f4e1b664bc46d329ff67f29ce380b71c1af36dd Mon Sep 17 00:00:00 2001 From: Rand Xie Date: Tue, 26 Jan 2021 14:15:35 -0800 Subject: [PATCH] Fix multiprocessing starmap to allow passing in zip (#13664) --- python/ray/tests/test_multiprocessing.py | 1 + python/ray/util/multiprocessing/pool.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/python/ray/tests/test_multiprocessing.py b/python/ray/tests/test_multiprocessing.py index 3f63b72db..8ec3cb43c 100644 --- a/python/ray/tests/test_multiprocessing.py +++ b/python/ray/tests/test_multiprocessing.py @@ -340,6 +340,7 @@ def test_starmap(pool): args = [tuple(range(i)) for i in range(100)] assert pool.starmap(f, args) == args + assert pool.starmap(lambda x, y: x + y, zip([1, 2], [3, 4])) == [4, 6] def test_callbacks(pool_4_processes): diff --git a/python/ray/util/multiprocessing/pool.py b/python/ray/util/multiprocessing/pool.py index 2d8f3d5fb..9910bc3a4 100644 --- a/python/ray/util/multiprocessing/pool.py +++ b/python/ray/util/multiprocessing/pool.py @@ -494,7 +494,7 @@ class Pool: def _chunk_and_run(self, func, iterable, chunksize=None, unpack_args=False): if not hasattr(iterable, "__len__"): - iterable = [iterable] + iterable = list(iterable) if chunksize is None: chunksize = self._calculate_chunksize(iterable)