set timeout
This commit is contained in:
parent
67b67d87fa
commit
7e4c062a13
1 changed files with 13 additions and 9 deletions
|
@ -95,12 +95,11 @@ class Sync(Thread):
|
|||
self.adjust_position()
|
||||
if self._pos != self.mpv.playlist_current_pos:
|
||||
self._pos = self.mpv.playlist_current_pos
|
||||
if self._pos != -1:
|
||||
try:
|
||||
track = self.mpv.playlist[self._pos]
|
||||
logger.error("%s %s", datetime.now(), track["filename"])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
track = self.mpv.playlist[self._pos]
|
||||
logger.error("%s %s", datetime.now(), track["filename"])
|
||||
except:
|
||||
pass
|
||||
|
||||
def reload_playlist(self):
|
||||
if not self.reload_check:
|
||||
|
@ -146,9 +145,14 @@ class Sync(Thread):
|
|||
#
|
||||
|
||||
def read_position_main(self):
|
||||
data = self.sock.recvfrom(1024)[0].decode().split(" ", 1)
|
||||
self.main.time_pos = float(data[0])
|
||||
self.main.playlist_current_pos = int(data[1])
|
||||
self.sock.settimeout(5)
|
||||
try:
|
||||
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):
|
||||
if self.mpv.time_pos is not None:
|
||||
|
|
Loading…
Reference in a new issue