def test_add_worker(self):
    master = Master(port=1234)
    th = threading.Thread(target=master.run)
    th.start()
    time.sleep(1)
    worker1 = Worker('localhost:1234', 4)
    self.assertEqual(master.cpu_num, 4)
    worker2 = Worker('localhost:1234', 4)
    self.assertEqual(master.cpu_num, 8)
    worker2.exit()
    time.sleep(30)
    self.assertEqual(master.cpu_num, 4)
    master.exit()
    worker1.exit()
def test_add_worker(self):
    master = Master(port=1234)
    th = threading.Thread(target=master.run)
    th.start()
    time.sleep(1)
    worker1 = Worker('localhost:1234', 4)
    self.assertEqual(master.cpu_num, 4)
    worker2 = Worker('localhost:1234', 4)
    self.assertEqual(master.cpu_num, 8)
    worker2.exit()
    time.sleep(30)
    self.assertEqual(master.cpu_num, 4)
    master.exit()
    worker1.exit()