'Test several threads, each with their own Connection and pipelined
requests.'

def test_multiple_threads_multiple_connections(self):

    num_requests_per_conn = 25
    num_conns = 5
    events = [Event() for i in range(5)]
    query = 'SELECT    keyspace_name    FROM    system.schema_keyspaces    LIMIT    1'
    def cb(conn, event, thread_responses, request_num, *args, **kwargs):
        thread_responses[request_num] = True
        if all(thread_responses):
            conn.close()
            event.set()
    def send_msgs(conn, event):
        thread_responses = ([False] * num_requests_per_conn)
        for i in range(num_requests_per_conn):
            qmsg = QueryMessage(query=query, consistency_level=ConsistencyLevel.ONE)
            with conn.lock:
                request_id = conn.get_request_id()
            conn.send_msg(qmsg, request_id, cb=partial(cb, conn, event, thread_responses, i))
        event.wait()
    threads = []
    for i in range(num_conns):
        conn = self.get_connection()
        t = Thread(target=send_msgs, args=(conn, events[i]))
        threads.append(t)
    for t in threads:
        t.start()
    for t in threads:
        t.join()
