avoid recursion

This commit is contained in:
j 2024-09-10 12:46:47 +01:00
parent e221626191
commit 45e2acbbb8

View file

@ -302,19 +302,23 @@ class Sync(Thread):
def read_position_main(self): def read_position_main(self):
self.sock.settimeout(5) self.sock.settimeout(5)
while True:
try: try:
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1) data = self.sock.recvfrom(1024)[0].decode().split(" ", 1)
except socket.timeout: except socket.timeout:
if self._last_ping != "pause": if self._last_ping != "pause":
logger.error("failed to receive data from main") logger.error("failed to receive data from main")
return
except OSError: except OSError:
logger.error("socket closed") logger.error("socket closed")
else: return
if CONFIG.get("sync_group"): if CONFIG.get("sync_group"):
if data[0] != str(CONFIG["sync_group"]): if data[0] == str(CONFIG["sync_group"]):
return self.read_position_main()
else:
data = data[1:] data = data[1:]
break
else:
break
self._last_ping = data[0] self._last_ping = data[0]
if data[0] == "pause": if data[0] == "pause":
self.is_paused = True self.is_paused = True