예제 #1
0
 def test_overflow_memory(self):
     """Отлавливает переполнение памяти"""
     process = ProcessPool(min_workers=2, max_workers=10, mem_usage='1Kb')
     with self.assertRaises(Exception) as context:
         process.map(heavy_computation, self.data())
     self.assertTrue('Процесс занимает больше памяти, чем возможно' in str(
         context.exception))
예제 #2
0
 def test_amount_processes_less_than_min_workers(self):
     """Количество возможных процессов меньше мин. кол-ва"""
     process = ProcessPool(min_workers=5000,
                           max_workers=5100,
                           mem_usage='150mb')
     data = self.data()
     with self.assertRaises(Exception) as context:
         process.map(heavy_computation, data)
     u = 'Количество возможных процессов меньше минимального количества' in str(
         context.exception)
     self.assertTrue(u)
예제 #3
0
 def test_qsize_less_amount_process(self):
     process = ProcessPool(min_workers=1, max_workers=10, mem_usage='150mb')
     data = self.data()
     result = process.map(heavy_computation, data)
     self.assertEqual(result[0], len(data))
예제 #4
0
 def test_mem_usage(self):
     process = ProcessPool(min_workers=1, max_workers=10, mem_usage='100mb')
     result = process.map(heavy_computation, self.data())
     self.assertLessEqual(result[0] * result[1], 100)
예제 #5
0
 def test_max_less_possible(self):
     """Максимальная память меньше возможной"""
     process = ProcessPool(min_workers=1, max_workers=3, mem_usage='1gb')
     result = process.map(heavy_computation, self.data())
     self.assertEqual(3, result[0])