'Tests the behavior of the pool if a task throws an exception.'

def testRunRaisingTask(self):

    self.lock = threading.Lock()
    def IRaise(some_obj):
        'This    method    just    raises    an    exception.'
        with self.lock:
            some_obj.process()
    self.exception_args = []
    def MockException(*args):
        self.exception_args = args
    with utils.Stubber(logging, 'exception', MockException):
        self.test_pool.AddTask(IRaise, (None,), 'Raising')
        self.test_pool.AddTask(IRaise, (None,), 'Raising')
        self.test_pool.Join()
    self.assertTrue(self.exception_args[0], 'exception    in    worker    thread')
    self.assertTrue(self.exception_args[1], 'Raising')
    self.assertEqual(stats.STATS.GetMetricValue((self.test_pool.name + '_task_exceptions')), 2)
