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):
self.sock.settimeout(5)
while True:
try:
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1)
except socket.timeout:
if self._last_ping != "pause":
logger.error("failed to receive data from main")
return
except OSError:
logger.error("socket closed")
else:
return
if CONFIG.get("sync_group"):
if data[0] != str(CONFIG["sync_group"]):
return self.read_position_main()
else:
if data[0] == str(CONFIG["sync_group"]):
data = data[1:]
break
else:
break
self._last_ping = data[0]
if data[0] == "pause":
self.is_paused = True