'Could block while we wait for the pool to become non-empty.
@param get_client_timeout: how long (in seconds) to wait on the pool
to get a client before failing'

def get_client(self, conf, get_client_timeout=None):

    if (_get_pool_key(conf) not in self.pooldict):
        self.dictlock.acquire()
        try:
            if (_get_pool_key(conf) not in self.pooldict):
                q = LifoQueue(self.poolsize)
                for i in xrange(self.poolsize):
                    client = construct_superclient(conf)
                    client.CID = i
                    q.put(client, False)
                self.pooldict[_get_pool_key(conf)] = q
        finally:
            self.dictlock.release()
    connection = None
    start_pool_get_time = time.time()
    has_waited_for = 0
    while (connection is None):
        if (get_client_timeout is not None):
            this_round_timeout = max(min((get_client_timeout - has_waited_for), 1), 0)
        else:
            this_round_timeout = None
        try:
            connection = self.pooldict[_get_pool_key(conf)].get(block=True, timeout=this_round_timeout)
        except Queue.Empty:
            has_waited_for = (time.time() - start_pool_get_time)
            if ((get_client_timeout is not None) and (has_waited_for > get_client_timeout)):
                raise socket.timeout((('Timed    out    after    %.2f    seconds    waiting    to    retrieve    a    ' + '%s    client    from    the    pool.') % (has_waited_for, conf.service_name)))
            logging.warn(('Waited    %d    seconds    for    a    thrift    client    to    %s:%d' % (has_waited_for, conf.host, conf.port)))
    return connection
