set timeout

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

View file

@ -95,12 +95,11 @@ 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"]) except:
except: pass
pass
def reload_playlist(self): def reload_playlist(self):
if not self.reload_check: if not self.reload_check:
@ -146,9 +145,14 @@ class Sync(Thread):
# #
def read_position_main(self): def read_position_main(self):
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1) self.sock.settimeout(5)
self.main.time_pos = float(data[0]) try:
self.main.playlist_current_pos = int(data[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.playlist_current_pos = int(data[1])
def adjust_position(self): def adjust_position(self):
if self.mpv.time_pos is not None: if self.mpv.time_pos is not None: