File tree Expand file tree Collapse file tree 2 files changed +3
-20
lines changed
src/clusterfuzz/_internal Expand file tree Collapse file tree 2 files changed +3
-20
lines changed Original file line number Diff line number Diff line change 21
21
POOL_SIZE = multiprocessing .cpu_count ()
22
22
23
23
24
- class SingleThreadPool :
25
- """Single thread pool for when it's not worth using Python's thread
26
- implementation."""
27
-
28
- def __init__ (self , size ):
29
- del size
30
-
31
- def map (self , f , l ):
32
- return list (map (f , l ))
33
-
34
- def imap_unordered (self , f , l ):
35
- return list (map (f , l ))
36
-
37
-
38
24
@contextlib .contextmanager
39
- def make_pool (pool_size = POOL_SIZE , cpu_bound = False , max_pool_size = None ):
25
+ def make_pool (pool_size = POOL_SIZE , max_pool_size = None ):
40
26
"""Returns a pool that can (usually) execute tasks concurrently."""
41
27
if max_pool_size is not None :
42
28
pool_size = min (pool_size , max_pool_size )
43
29
44
30
# Don't use processes on Windows and unittests to avoid hangs.
45
31
if (environment .get_value ('PY_UNITTESTS' ) or
46
32
environment .platform () == 'WINDOWS' ):
47
- if cpu_bound :
48
- yield SingleThreadPool (pool_size )
49
- else :
50
- yield futures .ThreadPoolExecutor (pool_size )
33
+ yield futures .ThreadPoolExecutor (pool_size )
51
34
else :
52
35
yield futures .ProcessPoolExecutor (pool_size )
53
36
Original file line number Diff line number Diff line change @@ -1383,7 +1383,7 @@ def parallel_map(func, argument_list):
1383
1383
will OOM."""
1384
1384
max_size = 2
1385
1385
timeout = 120
1386
- with concurrency .make_pool (cpu_bound = True , max_pool_size = max_size ) as pool :
1386
+ with concurrency .make_pool (max_pool_size = max_size ) as pool :
1387
1387
calls = {pool .submit (func , argument ) for argument in argument_list }
1388
1388
while calls :
1389
1389
finished_calls , _ = futures .wait (
You can’t perform that action at this time.
0 commit comments