Ejemplo n.º 1
0
 def test_results_order(self):
     def func(x):
         time.sleep(x)
         return x
     values = tuple(random.random() * 0.1 for x in range(10))
     results = concurrent.tmap(func, values)
     expected = [concurrent.Result(True, x) for x in values]
     self.assertEqual(results, expected)
Ejemplo n.º 2
0
 def test_results_order(self):
     def func(x):
         time.sleep(x)
         return x
     values = tuple(random.random() * 0.1 for x in range(10))
     results = concurrent.tmap(func, values)
     expected = [concurrent.Result(True, x) for x in values]
     self.assertEqual(results, expected)
Ejemplo n.º 3
0
    def test_error(self):
        error = RuntimeError("No result for you!")

        def func(x):
            raise error

        results = concurrent.tmap(func, range(10))
        expected = [concurrent.Result(False, error)] * 10
        self.assertEqual(results, expected)
Ejemplo n.º 4
0
    def test_error(self):
        error = RuntimeError("No result for you!")

        def func(x):
            raise error

        results = concurrent.tmap(func, range(10))
        expected = [concurrent.Result(False, error)] * 10
        self.assertEqual(results, expected)
Ejemplo n.º 5
0
 def test_concurrency(self):
     start = time.time()
     concurrent.tmap(time.sleep, [0.5] * 10)
     elapsed = time.time() - start
     self.assertGreater(elapsed, 0.5)
     self.assertLess(elapsed, 1.0)
Ejemplo n.º 6
0
 def test_results(self):
     values = tuple(range(10))
     results = concurrent.tmap(lambda x: x, values)
     expected = [concurrent.Result(True, x) for x in values]
     self.assertEqual(results, expected)
Ejemplo n.º 7
0
 def test_concurrency(self):
     start = time.time()
     concurrent.tmap(time.sleep, [0.1] * 10)
     elapsed = time.time() - start
     self.assertTrue(0.1 < elapsed < 0.2)
Ejemplo n.º 8
0
 def test_results(self):
     values = tuple(range(10))
     results = concurrent.tmap(lambda x: x, values)
     expected = [concurrent.Result(True, x) for x in values]
     self.assertEqual(results, expected)
Ejemplo n.º 9
0
 def test_concurrency(self):
     start = time.time()
     concurrent.tmap(time.sleep, [0.1] * 10)
     elapsed = time.time() - start
     self.assertTrue(0.1 < elapsed < 0.2)
Ejemplo n.º 10
0
 def test_concurrency(self):
     start = time.time()
     concurrent.tmap(time.sleep, [0.5] * 10)
     elapsed = time.time() - start
     self.assertGreater(elapsed, 0.5)
     self.assertLess(elapsed, 1.0)