• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from __future__ import print_function
6
7from typing import Optional
8
9from pathos import pools
10
11
12def GetProcessPool(nodes: Optional[int] = None) -> pools.ProcessPool:
13  """Returns a pathos.pools.ProcessPool instance.
14
15  Split out for ease of unittesting since pathos can still run into pickling
16  issues with MagicMocks used in tests.
17
18  Args:
19    nodes: How many processes processes to spawn in the process pool.
20
21  Returns:
22    A pathos.pools.ProcessPool instance.
23  """
24  return pools.ProcessPool(nodes=nodes)
25