Exemplo n.º 1
0
    def test_threads_force_join(self):

        q = Queue()
        t1 = InstaDownloader(q, None, None)
        t2 = InstaDownloader(q, None, None)

        t1.start()
        t2.start()

        self.assertTrue(t1.is_alive())
        self.assertTrue(t2.is_alive())

        threadutils.threads_force_join()

        self.assertFalse(t1.is_alive())
        self.assertFalse(t2.is_alive())
Exemplo n.º 2
0
    def test_threads_count(self):

        q = Queue()
        t1 = InstaDownloader(q, None, None)
        t2 = InstaDownloader(q, None, None)

        try:
            self.assertEqual(threadutils.threads_count(), 0)
            t1.start()
            self.assertEqual(threadutils.threads_count(), 1)
            t2.start()
            self.assertEqual(threadutils.threads_count(), 2)
        finally:
            t1.terminate()
            t2.terminate()