'Test sharing a single connections across multiple threads,
which will result in pipelined requests.'

def test_multiple_threads_shared_connection(self):

    num_requests_per_conn = 25
    num_threads = 5
    event = Event()
    conn = self.get_connection()
    query = 'SELECT    keyspace_name    FROM    system.schema_keyspaces    LIMIT    1'
    def cb(all_responses, thread_responses, request_num, *args, **kwargs):
        thread_responses[request_num] = True
        if all(map(all, all_responses)):
            conn.close()
            event.set()
    def send_msgs(all_responses, thread_responses):
        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, all_responses, thread_responses, i))
    all_responses = []
    threads = []
    for i in range(num_threads):
        thread_responses = ([False] * num_requests_per_conn)
        all_responses.append(thread_responses)
        t = Thread(target=send_msgs, args=(all_responses, thread_responses))
        threads.append(t)
    for t in threads:
        t.start()
    for t in threads:
        t.join()
    event.wait()
