def _get_server(self):
        with self._lock:
            try:
                ts, server = heapq.heappop(self._inactive_servers)
            except IndexError:
                pass
            else:
                if ts > time():  # Not yet, put it back
                    heapq.heappush(self._inactive_servers, (ts, server))
                else:
                    self._active_servers.append(server)
                    logger.info("Restored server %s into active pool", server)

            try:
                return random.choice(self._active_servers)
            except IndexError as ex:
                raise NoServerAvailable(ex)
dataset/ETHPy150Open aparo/pyes/pyes/connection_http.py/Connection._get_server/original