Skip to content

Commit

Permalink
Fix code format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
maxzheng committed Sep 28, 2023
1 parent c100972 commit 1e7777a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 0 additions & 2 deletions metaflow/multicore_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,13 @@ def _spawn(func, arg, dir):


def parallel_imap_unordered(func, iterable, max_parallel=None, dir=None):

if max_parallel is None:
max_parallel = cpu_count()

args_iter = iter(iterable)
pids = [_spawn(func, arg, dir) for arg in islice(args_iter, max_parallel)]

while pids:

for idx, pid_info in enumerate(pids):
pid, output_file = pid_info
pid, exit_code = os.waitpid(pid, os.WNOHANG)
Expand Down
9 changes: 8 additions & 1 deletion test/unit/test_multicore_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@


def test_parallel_map():
assert parallel_map(lambda s: s.upper(), ['a', 'b', 'c', 'd', 'e', 'f']) == ['A', 'B', 'C', 'D', 'E', 'F']
assert parallel_map(lambda s: s.upper(), ["a", "b", "c", "d", "e", "f"]) == [
"A",
"B",
"C",
"D",
"E",
"F",
]

0 comments on commit 1e7777a

Please sign in to comment.