Example #1
0
class TestThreadedExecutorException(object):
    def setup(self):
        self.lock = threading.Lock()
        self.exec_count = 0
        self.te = ThreadPool(size=2)
    def execute(self, x):
        time.sleep(0.005)
        with self.lock:
            self.exec_count += 1
            if self.exec_count == 7:
                raise DummyException()
        return x
    def test_execute_w_exception(self):
        try:
            self.te.map(self.execute, range(100))
        except DummyException:
            print self.exec_count
            assert 7 <= self.exec_count <= 10, 'execution should be interrupted really '\
                                               'soon (exec_count should be 7+(max(3)))'
        else:
            assert False, 'expected DummyException'
Example #2
0
class TestThreadedExecutorException(object):
    def setup(self):
        self.lock = threading.Lock()
        self.exec_count = 0
        self.te = ThreadPool(size=2)

    def execute(self, x):
        time.sleep(0.005)
        with self.lock:
            self.exec_count += 1
            if self.exec_count == 7:
                raise DummyException()
        return x

    def test_execute_w_exception(self):
        try:
            self.te.map(self.execute, list(range(100)))
        except DummyException:
            print(self.exec_count)
            assert 7 <= self.exec_count <= 10, 'execution should be interrupted really '\
                                               'soon (exec_count should be 7+(max(3)))'
        else:
            assert False, 'expected DummyException'
Example #3
0
 def setup(self):
     self.lock = threading.Lock()
     self.exec_count = 0
     self.te = ThreadPool(size=2)
Example #4
0
 def test2():
     with local_base_config(conf2):
         pool2 = ThreadPool(5)
         list(pool2.imap(check2, list(range(200))))
Example #5
0
 def test1():
     with local_base_config(conf1):
         pool1 = ThreadPool(5)
         list(pool1.imap(check1, list(range(200))))
Example #6
0
 def mk_pool(self):
     return ThreadPool()
Example #7
0
 def setup(self):
     self.lock = threading.Lock()
     self.exec_count = 0
     self.te = ThreadPool(size=2)
Example #8
0
 def test2():
     with local_base_config(conf2):
         pool2 = ThreadPool(5)
         list(pool2.imap(check2, range(200)))
Example #9
0
 def test1():
     with local_base_config(conf1):
         pool1 = ThreadPool(5)
         list(pool1.imap(check1, range(200)))