Skip to content

Commit

Permalink
support non-daemonic subprocesses
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjun Barrett committed Jun 11, 2024
1 parent d9cb43d commit 456976c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/vmaf/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import unittest
from fnmatch import fnmatch
import multiprocessing
from concurrent.futures import ProcessPoolExecutor
from time import sleep, time
import itertools
from pathlib import Path
Expand Down Expand Up @@ -336,8 +337,10 @@ def pool_init():
_pm_list_args = list_args
_pm_return_dict = return_dict

with context.Pool(processes, initializer=pool_init) as pool:
pool.map(_parallel_map_rt, range(len(list_args)))
with ProcessPoolExecutor(processes, mp_context=context, initializer=pool_init) as pool:
# ProcessPoolExecutor prevents hanging on the slowest processes that get too much work - delegates one at a time
for _ in pool.map(_parallel_map_rt, range(len(list_args))):
pass

return [return_dict[i] for i in range(len(list_args))]

Expand Down

0 comments on commit 456976c

Please sign in to comment.