@mock.patch('socket.create_connection')
    def test_copy_thread(self, socket):

        err = []
        copy = KafkaConnection('kafka', 9092).copy()

        def thread_func(err, copy):
            try:
                self.assertEqual(copy.host, 'kafka')
                self.assertEqual(copy.port, 9092)
                self.assertNotEqual(copy._sock, None)
            except Exception as e:
                err.append(e)
            else:
                err.append(None)
        thread = Thread(target=thread_func, args=(err, copy))
        thread.start()
        thread.join()

        self.assertEqual(err, [None])
        self.assertEqual(socket.call_count, 2)
This is a useful method if you need to print out the alarm morefs
dataset/ETHPy150Open dpkp/kafka-python/test/test_conn_legacy.py/TestKafkaConnection.test_copy_thread--crossover with--dataset/ETHPy150Open vmware/pyvmomi-community-samples/samples/tools/alarm.py/print_triggered_alarms