예제 #1
0
    def test_diamond_shape(self):
        q = Queue()

        a = Thread(target = queue_echo, args = [q, 'a'])
        b = Thread(target = queue_echo, args = [q, 'b'])
        c = Thread(target = queue_echo, args = [q, 'c'])
        d = Thread(target = queue_echo, args = [q, 'd'])
        
        b.depends_on(a)
        c.depends_on(a)

        d.depends_on(b)
        d.depends_on(c)

        [t.start() for t in (a,b,c,d)]
        [t.join(join_timeout) for t in (a,b,c,d)]

        self.assertEqual(q.get(), 'a')
        q.get()
        q.get()
        self.assertEqual(q.get(), 'd')
예제 #2
0
    def test_two_threads(self):
        first = Thread(target = dummy_fun)
        second = Thread(target = dummy_fun)

        second.depends_on(first)

        first.start()
        second.start()

        first.join(join_timeout)
        second.join(join_timeout)
예제 #3
0
 def test_multiple_starts(self):
     t = Thread(target = dummy_fun)
     t.start()
     t.join(join_timeout)
     
     self.assertRaises(RuntimeError, t.start )
예제 #4
0
 def test_single(self):
     t = Thread(target = dummy_fun)
     t.start()
     t.join(join_timeout)