def initialize_connection(self):
        """Initialize a socket to a Chromecast, retrying as necessary."""
        tries = self.tries

        if self.socket is not None:
            self.socket.close()
            self.socket = None

        # Make sure nobody is blocking.
        for callback in self._request_callbacks.values():
            callback['event'].set()

        self.app_namespaces = []
        self.destination_id = None
        self.session_id = None
        self._request_id = 0
        self._request_callbacks = {}
        self._open_channels = []

        self.connecting = True
        retry_log_fun = self.logger.exception

        while not self.stop.is_set() and (tries is None or 0 > tries):
            try:
                self.socket = ssl.wrap_socket(socket.socket())
                self.socket.settimeout(self.timeout)
                self._report_connection_status(
                    ConnectionStatus(CONNECTION_STATUS_CONNECTING,
                                     NetworkAddress(self.host, self.port)))
                self.socket.connect((self.host, self.port))
                self.connecting = False
                self._force_recon = False
                self._report_connection_status(
                    ConnectionStatus(CONNECTION_STATUS_CONNECTED,
                                     NetworkAddress(self.host, self.port)))
                self.receiver_controller.update_status()
                self.heartbeat_controller.ping()
                self.heartbeat_controller.reset()

                self.logger.debug("Connected!")
                break
            except socket.error:
                self.connecting = True
                if self.stop.is_set():
                    self.logger.exception(
                        "Failed to connect, aborting due to stop signal.")
                    raise ChromecastConnectionError("Failed to connect")

                self._report_connection_status(
                    ConnectionStatus(CONNECTION_STATUS_FAILED,
                                     NetworkAddress(self.host, self.port)))
                retry_log_fun("Failed to connect, retrying in %fs",
                              self.retry_wait)
                retry_log_fun = self.logger.debug

                time.sleep(self.retry_wait)
                if tries:
                    tries -= 1
        else:
            self.stop.set()
            self.logger.error("Failed to connect. No retries.")
            raise ChromecastConnectionError("Failed to connect")
dataset/ETHPy150Open balloob/pychromecast/pychromecast/socket_client.py/SocketClient.initialize_connection/swapped operands of `>`