def _create_connection(self): try: with timeout(15, exception=RuntimeError): self._token = login(self._user, self._password) self._conn = HarmonyClient(self._token) print "he" + str(self._ip) + ":" + str(self._port) self._conn.connect(address=(self._ip, self._port), use_tls=False, use_ssl=False) print 'adf' self._conn.process(block=False) while not self._conn.sessionstarted: time.sleep(0.1) except RuntimeError: self._logger.error("Harmony: Connection error") raise RuntimeError return False return True