Example #1
0
    def test_lifecycle_2(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()
Example #2
0
    def test_lifecycle_2(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()
Example #3
0
    def test_raise_error_join(self):
        def run():
            time.sleep(0.5)
            raise ValueError("raise_error_join")

        thread = Thread(target=run)
        thread.start()
        with self.assertRaises(ValueError):
            thread.join()
Example #4
0
    def test_success(self):
        q = queue.Queue()
        def run():
            q.put(2)

        thread = Thread(target=run)
        thread.start()
        thread.join()
        self.assertEqual(2, q.get(False)) 
Example #5
0
    def test_raise_error_start(self):
        def run():
            raise ValueError("raise_error_start")

        thread = Thread(target=run)
        with self.assertRaises(KeyboardInterrupt):
            thread.start()
            while thread.is_alive():
                time.sleep(0.1)

        self.assertIsInstance(thread.exception, ValueError)
Example #6
0
    def test_raise_error_start(self):
        def run():
            raise ValueError("raise_error_start")

        thread = Thread(target=run)
        with self.assertRaises(KeyboardInterrupt):
            thread.start()
            while thread.is_alive():
                time.sleep(0.1)

        self.assertIsInstance(thread.exception, ValueError)
Example #7
0
    def test_lifecycle_1(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 1")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        while not thread.exception:
            pass

        pout.v(thread.exception)
Example #8
0
    def test_lifecycle_1(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 1")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        while not thread.exception:
            pass

        pout.v(thread.exception)
Example #9
0
    def test_raise_error_daemon_join(self):
        def run():
            time.sleep(0.5)
            raise ValueError("raise_error_daemon_join")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()
        with self.assertRaises(ValueError):
            thread.join()
Example #10
0
    def test_success(self):
        q = queue.Queue()
        def run():
            q.put(2)

        thread = Thread(target=run)
        thread.start()
        thread.join()
        self.assertEqual(2, q.get(False)) 
Example #11
0
    def test_join_2(self):
        def run():
            time.sleep(0.5)
            raise ValueError("join_2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        try:
            thread.join()

        except ValueError as e:
            self.assertEqual("join_2", str(e))
Example #12
0
    def test_join_2(self):
        def run():
            time.sleep(0.5)
            raise ValueError("join_2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        try:
            thread.join()

        except ValueError as e:
            self.assertEqual("join_2", str(e))