# Path: pysc2/lib/run_parallel.py
# class RunParallel(object):
#   def __init__(self, timeout=None):
#   def run(self, funcs):
#   def shutdown(self, wait=True):
#   def __del__(self):


import threading
from absl.testing import absltest
from pysc2.lib import run_parallel
    out = pool.run([int])
    self.assertListEqual(out, [0])
    out = pool.run([lambda: 1, lambda: 2, lambda: "asdf", lambda: {1: 2}])
    self.assertListEqual(out, [1, 2, "asdf", {1: 2}])

  def test_run_in_parallel(self):
    b = Barrier(3)
    pool = run_parallel.RunParallel()
    out = pool.run([b.wait, b.wait, b.wait])
    self.assertItemsEqual(out, [0, 1, 2])

  def test_avoids_deadlock(self):
    b = Barrier(2)
    pool = run_parallel.RunParallel(timeout=2)
    with self.assertRaises(ValueError):
      pool.run([int, b.wait, bad])
    # Release the thread waiting on the barrier so the process can exit cleanly.
    b.clear()

  def test_exception(self):
    pool = run_parallel.RunParallel()
    out = pool.run([lambda: 1, ValueError])
    self.assertEqual(out[0], 1)
    self.assertIsInstance(out[1], ValueError)
    with self.assertRaises(ValueError):
      pool.run([bad])
    with self.assertRaises(ValueError):
      pool.run([int, bad])

  def test_partial(self):

# Path: pysc2/lib/run_parallel.py
# class RunParallel(object):
#   def __init__(self, timeout=None):
#   def run(self, funcs):
#   def shutdown(self, wait=True):
#   def __del__(self):


# Path: pysc2/lib/run_parallel_test.py
import threading
from absl.testing import absltest
from pysc2.lib import run_parallel

    out = pool.run([int])
    self.assertListEqual(out, [0])
    out = pool.run([lambda: 1, lambda: 2, lambda: "asdf", lambda: {1: 2}])
    self.assertListEqual(out, [1, 2, "asdf", {1: 2}])

  def test_run_in_parallel(self):
    b = Barrier(3)
    pool = run_parallel.RunParallel()
    out = pool.run([b.wait, b.wait, b.wait])
    self.assertItemsEqual(out, [0, 1, 2])

  def test_avoids_deadlock(self):
    b = Barrier(2)
    pool = run_parallel.RunParallel(timeout=2)
    with self.assertRaises(ValueError):
      pool.run([int, b.wait, bad])
    # Release the thread waiting on the barrier so the process can exit cleanly.
    b.clear()

  def test_exception(self):
    pool = run_parallel.RunParallel()
    out = pool.run([lambda: 1, ValueError])
    self.assertEqual(out[0], 1)
    self.assertIsInstance(out[1], ValueError)
    with self.assertRaises(ValueError):
      pool.run([bad])
    with self.assertRaises(ValueError):
      pool.run([int, bad])

  def test_partial(self):

    pool = run_parallel.RunParallel()