def get_or_connect(self, address, authenticator=None):
        if address in self.connections:
            return ImmediateFuture(self.connections[address])
        else:
            with self._new_connection_mutex:
                if address in self._pending_connections:
                    return self._pending_connections[address]
                else:
                    authenticator = authenticator or self._cluster_authenticator
                    connection = self._new_connection_func(address,
                                                           connection_closed_callback=self._connection_closed,
                                                           message_callback=self._client.invoker._handle_client_message)

                    def on_auth(f):
                        if f.is_success():
                            self.logger.info("Authenticated with %s", f.result())
                            with self._new_connection_mutex:
                                self.connections[connection.endpoint] = f.result()
                                self._pending_connections.pop(address)
                            for on_connection_opened, _ in self._connection_listeners:
                                if on_connection_opened:
                                    on_connection_opened(f.resul())
                            return f.result()
                        else:
                            self.logger.debug("Error opening %s", connection)
                            with self._new_connection_mutex:
                                try:
                                    self._pending_connections.pop(address)
                                except __HOLE__:
                                    pass
                            raise f.exception(), None, f.traceback()

                    future = authenticator(connection).continue_with(on_auth)
                    if not future.done():
                        self._pending_connections[address] = future
                    return future
dataset/ETHPy150Open hazelcast/hazelcast-python-client/hazelcast/connection.py/ConnectionManager.get_or_connect