set timeout

This commit is contained in:
j 2023-11-08 10:23:06 +01:00
parent 67b67d87fa
commit 7e4c062a13

View file

@ -95,7 +95,6 @@ class Sync(Thread):
self.adjust_position() self.adjust_position()
if self._pos != self.mpv.playlist_current_pos: if self._pos != self.mpv.playlist_current_pos:
self._pos = self.mpv.playlist_current_pos self._pos = self.mpv.playlist_current_pos
if self._pos != -1:
try: try:
track = self.mpv.playlist[self._pos] track = self.mpv.playlist[self._pos]
logger.error("%s %s", datetime.now(), track["filename"]) logger.error("%s %s", datetime.now(), track["filename"])
@ -146,7 +145,12 @@ class Sync(Thread):
# #
def read_position_main(self): def read_position_main(self):
self.sock.settimeout(5)
try:
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1) data = self.sock.recvfrom(1024)[0].decode().split(" ", 1)
except socket.timeout:
logger.error("failed to receive data from main")
else:
self.main.time_pos = float(data[0]) self.main.time_pos = float(data[0])
self.main.playlist_current_pos = int(data[1]) self.main.playlist_current_pos = int(data[1])